Greetings all,
I have a library called test which has a class that uses boost thread and
mutex. here is how the includes in my .h file look:
#include
#include
and here are the private vars:
boost::mutex connectedPeersMutex_;
boost::thread* listenThread_;
in the .cpp file i have I use:
#include
Now here is how I built my library with this Makefile:
SRC = test1.cpp test2.cpp
OBJ = $(SRC:.cpp=.o)
OUT = libtest.a
INCLUDES = -I. -I$$BOOST_ROOT
CCFLAGS = -g
CCC = g++
LDFLAGS = -g
.SUFFIXES: .cpp
default: $(OUT)
.cpp.o:
$(CCC) $(INCLUDES) $(CCFLAGS) -c $< -o $@
$(OUT): $(OBJ)
ar rcs $(OUT) $(OBJ)
clean:
rm -f $(OBJ) $(OUT) Makefile.bak
now I try to build a second application that simply uses the libtest.a like
this:
$ g++ -I ~/boost_1_38_0/ -I. main.cpp -omain -L/usr/local/lib/ -L. -ltest
-lboost_thread-gcc41-mt-1_38
./libtest.a(test1.o): In function `test1::StartServer(int,
std::basic_string,
int)':
/home/chris/test1.cpp:337: undefined reference to
`boost::thread::thread(boost::function0boost::function_base > const&)'
./libtest.a(test1.o): In function `~ test1':
/home/chris/test1.cpp:36: undefined reference to `boost::mutex::~mutex()'
/home/chris/test1.cpp:36: undefined reference to `boost::mutex::~mutex()'
/home/chris/test1.cpp:36: undefined reference to `boost::mutex::~mutex()'
/home/chris/test1.cpp:36: undefined reference to `boost::mutex::~mutex()'
/home/chris/test1.cpp:36: undefined reference to `boost::mutex::~mutex()'
./libtest.a(test1.o):/home/chris/test1.cpp:36: more undefined references to
`boost::mutex::~mutex()' follow
./libtest.a(test1.o): In function `test1':
/home/chris/test1.cpp:8: undefined reference to `boost::mutex::mutex()'
/home/chris/test1.cpp:8: undefined reference to `boost::mutex::mutex()'
./libtest.a(test1.o): In function
`boost::detail::thread::lock_opsboost::mutex::lock(boost::mutex&)':
/usr/include/boost/thread/detail/lock.hpp:33: undefined reference to
`boost::mutex::do_lock()'
./libtest.a(test1.o): In function
`boost::detail::thread::lock_opsboost::mutex::unlock(boost::mutex&)':
/usr/include/boost/thread/detail/lock.hpp:45: undefined reference to
`boost::mutex::do_unlock()'
collect2: ld returned 1 exit status
Any idea why I am getting these undefined references?
Thanks!
Christina
--
View this message in context: http://www.nabble.com/error-while-compiling-application-that-uses-a-static-l...
Sent from the Boost - Users mailing list archive at Nabble.com.