boost::disable_interruption problem

Hi. I'm trying to use boost package in Eclipse platform. In this line of code: boost::this_thread::disable_interruption di; Although boost-1.41.0-17 is installed and I have included boost/thread.hpp in the code, I receive the this error: undefined reference to 'boost::this_thread::disable_interruption::disable_interruption() I'm using CentOS 6 and gcc compiler. Anyone knows what's causing this problem?

On Tue, 07 May 2013 03:52:25 -0700, Mohammad Daei
Hi. I'm trying to use boost package in Eclipse platform. In this line of code:
boost::this_thread::disable_interruption di;
Although boost-1.41.0-17 is installed and I have included boost/thread.hpp in the code, I receive the this error:
undefined reference to 'boost::this_thread::disable_interruption::disable_interruption()
I'm using CentOS 6 and gcc compiler. Anyone knows what's causing this problem?
"Undefined references" usually indicate a linker error. Have you checked that you're linking against the thread library?

I've tried
"c++ -I /root/boost_1_53.0 example.cpp -o example",
"c++ -I /root/boost_1_53.0 example.cpp -o example -lboost_system-mt
-pthread",
"c++ -I /root/boost_1_53.0 example.cpp -o example -L
/root/boost_1_53.0/stage",
I've tried installing boost through yum, or downloading source package and
compiling them myself, still no luck
I'm really running out of ideas here!
On Wed, May 8, 2013 at 3:01 PM, Mostafa
On Tue, 07 May 2013 03:52:25 -0700, Mohammad Daei
wrote: Hi. I'm trying to use boost package in Eclipse platform. In this line of
code:
boost::this_thread::disable_**interruption di;
Although boost-1.41.0-17 is installed and I have included boost/thread.hpp in the code, I receive the this error:
undefined reference to 'boost::this_thread::disable_**interruption::disable_**interruption()
I'm using CentOS 6 and gcc compiler. Anyone knows what's causing this problem?
"Undefined references" usually indicate a linker error. Have you checked that you're linking against the thread library?
______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**usershttp://lists.boost.org/mailman/listinfo.cgi/boost-users

Did you try "-lboost_thread"?
---
Aaron Wright
From: Mohammad Daei

On Thu, 09 May 2013 08:07:39 -0700, Mohammad Daei
I've tried "c++ -I /root/boost_1_53.0 example.cpp -o example", "c++ -I /root/boost_1_53.0 example.cpp -o example -lboost_system-mt -pthread", "c++ -I /root/boost_1_53.0 example.cpp -o example -L /root/boost_1_53.0/stage", I've tried installing boost through yum, or downloading source package and compiling them myself, still no luck I'm really running out of ideas here!
The best way to get meaningful help is to post the smallest complete source file that produces the error, and the accompanying full error message(s). Also read up on what the compiler command line options "-L" and "-l" mean, if you're not familiar with them.

On Thu, May 9, 2013 at 3:33 PM, Mostafa
On Thu, 09 May 2013 08:07:39 -0700, Mohammad Daei
wrote:
I've tried "c++ -I /root/boost_1_53.0 example.cpp -o example", "c++ -I /root/boost_1_53.0 example.cpp -o example -lboost_system-mt -pthread", "c++ -I /root/boost_1_53.0 example.cpp -o example -L /root/boost_1_53.0/stage", I've tried installing boost through yum, or downloading source package and compiling them myself, still no luck I'm really running out of ideas here!
The best way to get meaningful help is to post the smallest complete source file that produces the error, and the accompanying full error message(s). Also read up on what the compiler command line options "-L" and "-l" mean, if you're not familiar with them.
Also there's http://vladimir_prus.blogspot.com/2009/06/linking-101.html

thanks for the help folks.
at first I tried "gcc example.cpp -o example -lboost_thread" which
resulted in the following error:
/usr/bin/ld: cannot find -lboost_thread
collect2: ld returned 1 exit status
I tried this and finally it worked: "gcc example.cpp -o example -L
/root/boost_1_53_0/stage/lib/ -lboost_thread -lboost_system"
I added the "/root/boost_1_53_0/stage/lib/" to Eclipse "Library Paths" on
the project properties under the "C/C++ General" section and also added
"boost_thread", "boost_system" , "boost_regex" and "boost_date_time" to
"Libraries" on the same section. after building and compiling the undefined
reference error for "boost::this_thread::disable_interruption" was removed
but I received two new errors. one of them is:
/usr/include/boost/thread/detail/thread.hpp:191: undefined
reference to `boost::thread::start_thread()'
and the other is:
/root/workspace/AMI2/Debug/../src/manager/ManagerEventsHandler.cpp:46:
undefined reference to `boost::thread::~thread()'
in the following piece of code:
#include
On Thu, May 9, 2013 at 3:33 PM, Mostafa
wrote: On Thu, 09 May 2013 08:07:39 -0700, Mohammad Daei
wrote: I've tried "c++ -I /root/boost_1_53.0 example.cpp -o example", "c++ -I /root/boost_1_53.0 example.cpp -o example -lboost_system-mt -pthread", "c++ -I /root/boost_1_53.0 example.cpp -o example -L /root/boost_1_53.0/stage", I've tried installing boost through yum, or downloading source package and compiling them myself, still no luck I'm really running out of ideas here!
The best way to get meaningful help is to post the smallest complete source file that produces the error, and the accompanying full error message(s). Also read up on what the compiler command line options "-L" and "-l" mean, if you're not familiar with them.
Also there's http://vladimir_prus.blogspot.com/2009/06/linking-101.html _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Fri, 10 May 2013 00:29:28 -0700, Mohammad Daei
I tried this and finally it worked: "gcc example.cpp -o example -L /root/boost_1_53_0/stage/lib/ -lboost_thread -lboost_system"
I added the "/root/boost_1_53_0/stage/lib/" to Eclipse "Library Paths" on the project properties under the "C/C++ General" section and also added "boost_thread", "boost_system" , "boost_regex" and "boost_date_time" to "Libraries" on the same section. after building and compiling the undefined reference error for "boost::this_thread::disable_interruption" was removed but I received two new errors. one of them is: /usr/include/boost/thread/detail/thread.hpp:191: undefined reference to `boost::thread::start_thread()'
and the other is:
/root/workspace/AMI2/Debug/../src/manager/ManagerEventsHandler.cpp:46: undefined reference to `boost::thread::~thread()' in the following piece of code: #include
#include #include void ManagerEventsHandler::fireEvent(const ManagerEvent& me) { boost::thread t(boost::bind(&ManagerEventsHandler::internalFireEvent, this, me)); } Given that I have included "boost/thread.hpp" in the source code and included the boost::thread library path and binaries in the project, what else should I do?
Mostafa I reviewed compiler options and I think I'm using them correctly. are there any flaws? Nat thanks for the link. it was very helpful.
At this point you have to do a process of elimination on your end to see why ManagerEventsHandler.cpp fails and example.cpp works. Have you tried building example.cpp stand-alone in Eclipse? I don't know what example.cpp is nor do I have a minimal and complete picture of the ManagerEventsHandler.cpp project, hence I can't think of anything more to help you.
participants (4)
-
Aaron_Wright@selinc.com
-
Mohammad Daei
-
Mostafa
-
Nat Linden