Hi all,
I've started just recently to use boost in my C++ application to manage
some threads. However, when I link my application I get strange
undefined references
g++ -g -O -o test_exe -lcppunit -ldl -lpthread -lboost_thread Main.o
test.o
test.o(.text+0x874): In function `threadTestCases::spawnThread()':
: undefined reference to `boost::thread::thread(boost::function0
You need to specify where boost headers are located,
-I/path-to-boost-headers.
-----Original Message-----
From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of Carl
Wainwright
Sent: Tuesday, May 08, 2007 11:56 AM
To: boost-users@lists.boost.org
Subject: [Boost-users] Undefined reference
Hi all,
I've started just recently to use boost in my C++ application to manage
some threads. However, when I link my application I get strange
undefined references
g++ -g -O -o test_exe -lcppunit -ldl -lpthread -lboost_thread Main.o
test.o
test.o(.text+0x874): In function `threadTestCases::spawnThread()':
: undefined reference to `boost::thread::thread(boost::function0
Carl Wainwright wrote:
Hi all,
I've started just recently to use boost in my C++ application to manage some threads. However, when I link my application I get strange undefined references
g++ -g -O -o test_exe -lcppunit -ldl -lpthread -lboost_thread Main.o test.o test.o(.text+0x874): In function `threadTestCases::spawnThread()': : undefined reference to `boost::thread::thread(boost::function0
boost::function_base > const&)' test.o(.text+0x8b7): In function `threadTestCases::spawnThread()': : undefined reference to `boost::thread::join()' test.o(.text+0x8ce): In function `threadTestCases::spawnThread()': : undefined reference to `boost::thread::~thread()' test.o(.text+0x8eb): In function `threadTestCases::spawnThread()': : undefined reference to `boost::thread::~thread()' collect2: ld returned 1 exit status make: *** [test_exe] Error 1 As you can see I have linked in the boost_thread and pthread but still I get the problem. My LD_LIBRARY_PATH is correctly setup to define the path where boost is installed (/usr/lib/)
Hi Carl, Try changing the order that you specify the arguments to g++. You'll want to put Main.o and test.o before the request to link in the libraries. Here is a link that has some more information (it is about DJGPP, but should hold true for your version of g++): http://www.delorie.com/djgpp/v2faq/faq8_10.html David
participants (3)
-
Carl Wainwright
-
David Walthall
-
Xu, Peng