Posix Thread

View: New views
6 Messages — Rating Filter:   Alert me  

Posix Thread

by hosseinyounesi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi , this is the first time I post a message on this forum. I tried to compile the thread example in the site with g++ and got this error :(    What should I do ?

/tmp/ccPU0lRI.o: In function `__static_initialization_and_destruction_0(int, int
)':
thread.cpp:(.text+0x151): undefined reference to `boost::mutex::mutex()'
/tmp/ccPU0lRI.o: In function `__tcf_1':
thread.cpp:(.text+0x19e): undefined reference to `boost::mutex::~mutex()'
/tmp/ccPU0lRI.o: In function `main':
thread.cpp:(.text+0x205): undefined reference to `boost::thread::thread(boost::f
unction0<void, std::allocator<boost::function_base> > const&)'
thread.cpp:(.text+0x24f): undefined reference to `boost::thread::thread(boost::f
unction0<void, std::allocator<boost::function_base> > const&)'
thread.cpp:(.text+0x29e): undefined reference to `boost::thread::join()'
thread.cpp:(.text+0x2a9): undefined reference to `boost::thread::join()'
thread.cpp:(.text+0x2bb): undefined reference to `boost::thread::~thread()'
thread.cpp:(.text+0x2ce): undefined reference to `boost::thread::~thread()'
thread.cpp:(.text+0x2de): undefined reference to `boost::thread::~thread()'
thread.cpp:(.text+0x2f7): undefined reference to `boost::thread::~thread()'
/tmp/ccPU0lRI.o: In function `boost::detail::thread::lock_ops<boost::mutex>::loc
k(boost::mutex&)':
thread.cpp:(.text._ZN5boost6detail6thread8lock_opsINS_5mutexEE4lockERS3_[boost::
detail::thread::lock_ops<boost::mutex>::lock(boost::mutex&)]+0xd): undefined ref
erence to `boost::mutex::do_lock()'
/tmp/ccPU0lRI.o: In function `boost::detail::thread::scoped_lock<boost::mutex>::
lock()':
thread.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE4lockEv[boost:
:detail::thread::scoped_lock<boost::mutex>::lock()]+0x28): undefined reference t
o `boost::lock_error::lock_error()'
thread.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE4lockEv[boost:                                                                            :detail::thread::scoped_lock<boost::mutex>::lock()]+0x30): undefined reference t                                                                            o `boost::lock_error::~lock_error()'
thread.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE4lockEv[boost:                                                                            :detail::thread::scoped_lock<boost::mutex>::lock()]+0x38): undefined reference t                                                                            o `typeinfo for boost::lock_error'
/tmp/ccPU0lRI.o: In function `boost::detail::thread::lock_ops<boost::mutex>::unl                                                                            ock(boost::mutex&)':
thread.cpp:(.text._ZN5boost6detail6thread8lock_opsINS_5mutexEE6unlockERS3_[boost                                                                            ::detail::thread::lock_ops<boost::mutex>::unlock(boost::mutex&)]+0xd): undefined                                                                             reference to `boost::mutex::do_unlock()'
/tmp/ccPU0lRI.o: In function `boost::detail::thread::scoped_lock<boost::mutex>::                                                                            unlock()':
thread.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE6unlockEv[boos                                                                            t::detail::thread::scoped_lock<boost::mutex>::unlock()]+0x2b): undefined referen                                                                            ce to `boost::lock_error::lock_error()'
thread.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE6unlockEv[boos                                                                            t::detail::thread::scoped_lock<boost::mutex>::unlock()]+0x33): undefined referen                                                                            ce to `boost::lock_error::~lock_error()'
thread.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE6unlockEv[boos                                                                            t::detail::thread::scoped_lock<boost::mutex>::unlock()]+0x3b): undefined referen                                                                            ce to `typeinfo for boost::lock_error'
collect2: ld returned 1 exit status

Re: Posix Thread

by Bugzilla from markus.schoepflin@comsoft.de :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hosseinyounesi wrote:

> Hi , this is the first time I post a message on this forum. I tried to
> compile the thread example in the site with g++ and got this error :(  
> What should I do ?

[...]

You need to link with the Boost.Thread library.

Markus

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Posix Thread

by hosseinyounesi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I used this command:

g++ asio_timer.cpp -L/usr/bin/libboost_thread.so

but it's contains the same error , Am I right in this command?


Markus Schöpflin wrote:
hosseinyounesi wrote:

> Hi , this is the first time I post a message on this forum. I tried to
> compile the thread example in the site with g++ and got this error :(  
> What should I do ?

[...]

You need to link with the Boost.Thread library.

Markus

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Posix Thread

by Bugzilla from markus.schoepflin@comsoft.de :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hosseinyounesi wrote:
> I used this command:
>
> g++ asio_timer.cpp -L/usr/bin/libboost_thread.so
>
> but it's contains the same error , Am I right in this command?

Try -lboost_thread instead of -L...

This should work, provided that boost has been installed into some default
location. (Check if there is a file called libboost_thread.[a|so] in /usr/lib.)

Markus

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Posix Thread

by Vladimir Prus-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hosseinyounesi wrote:

>
> I used this command:
>
> g++ asio_timer.cpp -L/usr/bin/libboost_thread.so
>
> but it's contains the same error , Am I right in this command?

No. I'd recommend you read up on linking with gcc/Linux.

-  Volodya


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Posix Thread

by hosseinyounesi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Fixed :0
Thank you  
Markus Schöpflin wrote:
hosseinyounesi wrote:
> I used this command:
>
> g++ asio_timer.cpp -L/usr/bin/libboost_thread.so
>
> but it's contains the same error , Am I right in this command?

Try -lboost_thread instead of -L...

This should work, provided that boost has been installed into some default
location. (Check if there is a file called libboost_thread.[a|so] in /usr/lib.)

Markus

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build