Problem compiling simple boost::thread code on Ubuntu9.10 :: GCC4.4.1 vs boost ?
Hi, I'm looking at developing a cross-platform application in C++ using the QT library && Netbeans on Ubuntu (9.10) and I'd like to be able to use Boost libs for threading so I've installed libboost1.40-all-dev. My version of gcc is :: 4.4.1 I've read there is a problem between this version of gcc and boost and that there is a patch somewhere. I'm a bit of a linux newbie so if anyone knows about this and can point me at the patch, it'd be great. I have followed a very straight forward example of how to use boost::thread from here --> http://www.drdobbs.com/cpp/184401518;jsessionid=OUWYLHI3ITUAHQE1GHOSKHWATMY3... Looking at the compiler output my inexperienced eyes are telling me the linker can't find the boost lib(s) it wants ? Any help or advice anyone can give will be greatly appreciated. Regards, Chris My code is as follows :: #include <QtGui/QApplication> #include <qt4/QtGui/qwidget.h> #include "qtMain.h" #include "DummySourceMgr.h" #include "DummySource.h" #include <boost/thread.hpp> void startDSM() { DummySourceMgr * dsm = new DummySourceMgr(); dsm->start(); } int main(int argc, char *argv[]) { // initialize resources, if needed // Q_INIT_RESOURCE(resfile); QApplication app(argc, argv); // create and show your widgets here qtMain * main = new qtMain(); main->show(); boost::thread systest1(&startDSM); systest1.join(); return app.exec(); } When I build in netbeans I get the following compiler output ::-> /usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .clean-conf make[1]: Entering directory `/home/dansonc/NetBeansProjects/StreamLaser' qmake VPATH=. -o qttmp-Debug.mk nbproject/qt-Debug.pro mv -f qttmp-Debug.mk nbproject/qt-Debug.mk /usr/bin/make -f nbproject/qt-Debug.mk distclean make[2]: Entering directory `/home/dansonc/NetBeansProjects/StreamLaser' rm -f moc_qtMain.cpp rm -f ui_qtMain.h rm -f build/Debug/GNU-Linux-x86/DummySource.o build/Debug/GNU-Linux-x86/qtMain.o build/Debug/GNU-Linux-x86/DummySourceMgr.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/moc_qtMain.o rm -f *~ core *.core rm -f dist/Debug/GNU-Linux-x86/StreamLaser rm -f qttmp-Debug.mk make[2]: Leaving directory `/home/dansonc/NetBeansProjects/StreamLaser' make[1]: Leaving directory `/home/dansonc/NetBeansProjects/StreamLaser' CLEAN SUCCESSFUL (total time: 428ms) /usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf make[1]: Entering directory `/home/dansonc/NetBeansProjects/StreamLaser' qmake VPATH=. -o qttmp-Debug.mk nbproject/qt-Debug.pro mv -f qttmp-Debug.mk nbproject/qt-Debug.mk /usr/bin/make -f nbproject/qt-Debug.mk dist/Debug/GNU-Linux-x86/StreamLaser make[2]: Entering directory `/home/dansonc/NetBeansProjects/StreamLaser' /usr/bin/uic-qt4 qtMain.ui -o ui_qtMain.h g++-4.4 -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -Inbproject -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -Inbproject -I. -o build/Debug/GNU-Linux-x86/DummySource.o DummySource.cpp DummySource.cpp:27: warning: unused parameter 'orig' DummySource.cpp: In member function 'void DummySource::start()': DummySource.cpp:36: warning: unused variable 'n' g++-4.4 -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -Inbproject -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -Inbproject -I. -o build/Debug/GNU-Linux-x86/qtMain.o qtMain.cpp g++-4.4 -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -Inbproject -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -Inbproject -I. -o build/Debug/GNU-Linux-x86/DummySourceMgr.o DummySourceMgr.cpp DummySourceMgr.cpp:15: warning: unused parameter 'orig' g++-4.4 -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -Inbproject -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -Inbproject -I. -o build/Debug/GNU-Linux-x86/main.o main.cpp /usr/bin/moc-qt4 -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -Inbproject -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -Inbproject -I. qtMain.h -o moc_qtMain.cpp g++-4.4 -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -Inbproject -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -Inbproject -I. -o build/Debug/GNU-Linux-x86/moc_qtMain.o moc_qtMain.cpp g++ -o dist/Debug/GNU-Linux-x86/StreamLaser build/Debug/GNU-Linux-x86/DummySource.o build/Debug/GNU-Linux-x86/qtMain.o build/Debug/GNU-Linux-x86/DummySourceMgr.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/moc_qtMain.o -L/usr/lib -lQtGui -lQtCore -lpthread build/Debug/GNU-Linux-x86/main.o: In function `main': /home/dansonc/NetBeansProjects/StreamLaser/main.cpp:44: undefined reference to `boost::thread::join()' /home/dansonc/NetBeansProjects/StreamLaser/main.cpp:47: undefined reference to `boost::thread::~thread()' /home/dansonc/NetBeansProjects/StreamLaser/main.cpp:47: undefined reference to `boost::thread::~thread()' build/Debug/GNU-Linux-x86/main.o: In function `mutex': /usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()' /usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::~thread_resource_error()' /usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `typeinfo for boost::thread_resource_error' build/Debug/GNU-Linux-x86/main.o: In function `condition_variable': /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: undefined reference to `boost::thread_resource_error::thread_resource_error()' /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: undefined reference to `boost::thread_resource_error::~thread_resource_error()' /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: undefined reference to `typeinfo for boost::thread_resource_error' build/Debug/GNU-Linux-x86/main.o: In function `thread_data_base': /usr/include/boost/thread/pthread/thread_data.hpp:54: undefined reference to `vtable for boost::detail::thread_data_base' build/Debug/GNU-Linux-x86/main.o: In function `thread<void (*)()>': /usr/include/boost/thread/detail/thread.hpp:188: undefined reference to `boost::thread::start_thread()' build/Debug/GNU-Linux-x86/main.o: In function `~thread_data': /usr/include/boost/thread/detail/thread.hpp:40: undefined reference to `boost::detail::thread_data_base::~thread_data_base()' /usr/include/boost/thread/detail/thread.hpp:40: undefined reference to `boost::detail::thread_data_base::~thread_data_base()' build/Debug/GNU-Linux-x86/main.o:(.rodata._ZTIN5boost6detail11thread_dataIPFvvEEE[typeinfo for boost::detail::thread_data<void (*)()>]+0x8): undefined reference to `typeinfo for boost::detail::thread_data_base' collect2: ld returned 1 exit status make[2]: *** [dist/Debug/GNU-Linux-x86/StreamLaser] Error 1 make[2]: Leaving directory `/home/dansonc/NetBeansProjects/StreamLaser' make[1]: *** [.build-conf] Error 2 make[1]: Leaving directory `/home/dansonc/NetBeansProjects/StreamLaser' make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 14s)
On Thursday 27 May 2010 00:45:51 octopusdesign.net wrote:
Hi,
I'm looking at developing a cross-platform application in C++ using the QT library && Netbeans on Ubuntu (9.10) and I'd like to be able to use Boost libs for threading so I've installed libboost1.40-all-dev.
My version of gcc is :: 4.4.1
I've read there is a problem between this version of gcc and boost and that there is a patch somewhere. I'm a bit of a linux newbie so if anyone knows about this and can point me at the patch, it'd be great.
If you installed both from the repository it's probably alreaddy applied. Distros usually keep their repository consistent. Also you need to pass -lboost_thread to the linker. You seem to be using qmake wich i don't think is verry seriously developed. You could have a look at moving to cmake wich seems to be the nicest build systems these days. I'd also reccomend you don't get into the habbit of relying too much on the ide especially on this kind of things. If you use linux it pays to learn to how to use the cli and you're pretty much expected to use the build tools directly.
participants (2)
-
Marius Stoica
-
octopusdesign.net