I try to compile small .cpp file with boost library on remote server on Debian using g++ 4.4. I use Netbeans for this purpose. My home machine is on windows 7. After resolving some issues with linking next code
#include <boost/timer/timer.hpp>
#include <iostream>
#include <string>
int main()
{
boost::timer::auto_cpu_timer ac; //line 5
return 0; //line 6
}
Produces 2 errors:
line 5: undefined reference to boost::timer::auto_cpu_timer::auto_cpu_timer(short)'
line 6: undefined reference to boost::timer::auto_cpu_timer::~auto_cpu_timer()'
Same result if i use header boost/thread.hpp
but for thread constructor/destructor.
But for example boost/shared_ptr
compiles without any problem.
Result compile command in neatbeans is
g++ -m64 -I/usr/include/boost/boost_1_49_0 -lboost_system -o dist/Debug/GNU-Linux-x86/test build/Debug/GNU-Linux-x86/main.o
-L/usr/include/boost/boost_1_49_0/stage/lib -Wl,-rpath /usr/include/boost/boost_1_49_0/stage/lib build/Debug/GNU-Linux-x86/main.o
What i missed?
You need to link against boost_timer. Add -lboost_timer
to the gcc command line. Consult the Netbeans documentation on how to add libraries to a project.