$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Carl Wainwright (Carl.Wainwright_at_[hidden])
Date: 2007-05-08 13:08:00
Hi there,
Surely if that was the case I would have received a compilation error.
As it is my code compiles without any errors/warnings which makes me
think it's a linker error or something else.
Additionally the headers for boost are in /usr/include/boost so I don't
believe I need to specify this include directive in my makefile
Cheers
Carl
|-----Original Message-----
|From: boost-users-bounces_at_[hidden] 
|[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Xu, Peng
|Sent: 08 May 2007 18:01
|To: boost-users_at_[hidden]
|Subject: Re: [Boost-users] Undefined reference
|
|You need to specify where boost headers are located, 
|-I/path-to-boost-headers.
|
|-----Original Message-----
|From: boost-users-bounces_at_[hidden]
|[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Carl 
|Wainwright
|Sent: Tuesday, May 08, 2007 11:56 AM
|To: boost-users_at_[hidden]
|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<void,
|std::allocator<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/)
|
|The code is as follows and is used in a CPPUNIT framework. The 
|boost code is in the spawnThread member function.
|
|//---------------------------------------------------------------------
|#include "test.h"
|#include <ostream>
|#include <pthread.h>
|
|#include <boost/thread/thread.hpp>
|#include <boost/bind.hpp>
|
|using namespace std;
|using namespace boost;
|
|CPPUNIT_TEST_SUITE_REGISTRATION( threadTestCases );
|
|void threadTestCases::setUp()
|{
|   cout << "\nthreadTestCases::setUp\n" << endl ; }
|
|void threadTestCases::tearDown()
|{
|   cout << "\nthreadTestCases::tearDown\n" << endl ; }
|
|void threadTestCases::testThread()
|{
|   cout << "Thread [testThread] spawned\n" << endl;
|
|   try
|   {
|      CPPUNIT_ASSERT(1 == 2);
|      cout << "Thread end" << endl;
|   }
|   catch(...)
|   {
|      cout << "Exception caught in testThread, continue\n" << endl;
|   }
|
|   pthread_exit(0);
|}
|
|void *my_thread(void *)
|{
|   cout << "Thread [my_thread] spawned\n" << endl ;
|
|   try
|   {
|      CPPUNIT_ASSERT(1 == 2);
|   }
|   catch(...)
|   {
|      cout << "Exception caught in my_thread, continue\n" << endl;
|   }
|
|   pthread_exit(0);
|}
|
|void threadTestCases::spawnThread()
|{
|pthread_t thread[2];
|int       ret;
|
|   cout << "\nSpawning new thread\n" << endl;
|
|   // Create thread via boost
|   boost::thread mfThread(boost::bind(&threadTestCases::testThread,
|this));
|
|   // Start execution of thread
|   mfThread.join();
|}
|
|
|Is there anything I have done wrong in the code or perhaps in 
|the build environment which is using Boost library v1.32.0-1 
|for Linux RedHat with
|g++ (GCC 3.4.6)
|
|Any help would be appreciated as this has been bugging me for 
|several hours today.
|
|Cheers
|Carl
|_______________________________________________
|Boost-users mailing list
|Boost-users_at_[hidden]
|http://listarchives.boost.org/mailman/listinfo.cgi/boost-users
|_______________________________________________
|Boost-users mailing list
|Boost-users_at_[hidden]
|http://listarchives.boost.org/mailman/listinfo.cgi/boost-users
|