Hello,
I have a C++ program, which calls a function (dsyeig(...)) from a C-library (libmrrr.a). The code for the library consists of a number of files. However, the function I am calling is situated in mrrr.h.
So, to call it, I have used extern "C"{}, where I include the library:
1 2 3
|
extern "C"{
#include "./mr3smp-master/INCLUDE/mrrr.h"
}
|
To link the library, I have created a makefile:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
DIRS = ./ ./m3smp-master/INCLUDE ./m3smp-master/INCLUDE/SRC
# Source files
HEADERS := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.h))
CSRCS := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.cpp))
COBJS = $(CSRCS:.cpp=.o)
# Build target #
RPApolar: $(COBJS) $(HEADERS)
g++ -o RPApolar $(COBJS) $(HEADERS) libmrrr.a -lpthread -static -L./libmrrr
.PHONY: clean
clean:
rm -f *~ core.* *__genmod* \
./INSTALL/*~ \
$(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.o)) \
$(foreach DIR,$(DIRS),$(wildcard $(DIR)/*~)) \
$(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.mod.*)) \
$(foreach DIR,$(DIRS),$(wildcard $(DIR)/*__genmod*)) */
|
When building the program RPApolar, the libmrrr is found and seems to be correctly linked. However, I get many linker errors as this one:
libmrrr.a(dense.o): In function 'dsyeig': /home/magdyn/.../SRC/dense.c:211: undefined reference to 'dsytrd_'
So, it seems, as if the linker cannot link correctly to the file dense.h, which is called by the library-internal function dsyeig. What do I have to change in my make file to have the linker linking correctly?
Thanks in advance for any advice.