I’m trying to compile a C++ program under Ubuntu 11.10 using boost 1.42 installed from the repository (I also tried building boost myself, but the result is the same as with the repo-boost). The source files compile but the linker gives errors… I tried for hours but couldn’t find a solution to this, maybe someone can help me…
Here’s the target from the Makefile
CXX = /usr/bin/g++
LDFLAGS = -L. \
-Lpath/to/libMy_Lib.a
CFLAGS = -I. \
-Wall \
-g \
-O0
OBJECTS = obj1.o obj2.o
%.o: %.cpp
$(CXX) -c $*.cpp -o $@ \
-Wno-deprecated \
$(CFLAGS)
all: program
program: $(OBJECTS)
$(CXX) $^ \
$(LDFLAGS) \
-o myProg \
-lboost_regex \
-lboost_filesystem \
-lboost_date_time \
-lboost_system \
-lboost_thread \
-lMy_Lib
libMy_Lib.a is a library which also uses boost (I had no problems compiling it on the same system). All the libs look ok in /usr/lib…
Here is the output ld generates (I used make 2> output) http://ubuntuone.com/6QlU7AUZGgLGIu7sHbvDHm
Maybe the order of the libraries isn’t correct (I know boost_filesystem depends on boost_system, but I’m not sure about the rest) or I forgot to specify some additional libs on which my program needs to link to…
This really buggs me and I feel like I’m blind to not see it…
Those error messages are impressive:
I added a newline before the ‘undefined reference’…
I think you should probably list your library, which uses Boost functions, before any of the Boost libraries.