I'm struggling to link a project to an external project (named Prog). I'm not used with big project and dependecies problem, It's the first time I encounter such problem to link another library.
I want to include this library as a static or better, as a dynamic library to MyProject. The compilation of Prog gives me static libraries (".a"), I included them to my "basic" Makefile, here is a picture of it :
Makefile :
CXX = g++
SRCS = $(shell find . -name "*.cpp")
OBJS = $(addsuffix .o, $(basename $(SRCS))
EXEC = test
CXXFLAGS += -std=c++17 -O3
LIBS = -L/usr/include/lib -lprogvcore \
-lpthread -lz -lm
CXXFLAGS += -I/usr/local/include/code \
-std=c++11 -O3
all : $(EXEC)
$(EXEC): $(OBJS)
@$(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
%.o: %.cpp
@$(CXX) -o $@ -c $< $(CXXFLAGS) $(LIBS)
.PHONY: clean mrproper
clean:
@rm -f $(OBJS)
mrproper: clean
@rm -rf $(EXEC)
Here is a picture of the project hierarchy :
MyProject
|
|
|------ TESTMain.cpp
|
|------ TESTFILES_THAT_USE_PROG_FUNCTIONS
| |
| |------ MC
| | |
| | |------- PROG.cpp
| | |------- PROG.h
|
|------ PROG-Project
|
|------ Makefile
When I run, the compiler recognizes the headers of PROG files, but when I want to use PROG functions it returns :
MC/PROG.o : In function « PROG::createModel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) » :
/home/git/test/test-src/MC/PROG.cpp:37 : underfined reference to « PROGCore_init_data() »
/home/git/test/test-src/MC/PROG.cpp:41 : underfined reference to « PROGCore_init(PROGEnv_TAG*, void (* (*) [2])(PROGEnv_TAG*), int) »
collect2: error: ld returned 1 exit status
Makefile:46: recipe for target 'test' failed
make: *** [test] Error 1
I tried to generate dynamic library to avoid the problem of ordering the libraries, but didn't work.
Excuse my english, but I hope my problem was clear.
Thank you.