对boost :: timer :: auto_cpu_timer的未定义引用 [英] Undefined reference to boost::timer::auto_cpu_timer

查看:325
本文介绍了对boost :: timer :: auto_cpu_timer的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用g ++ 4.4在Debian上的远程服务器上使用boost库编译小的.cpp文件。我为此目的使用Netbeans。我的家用计算机在Windows 7上。解决了链接下一个代码的一些问题之后

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
}

产生2个错误:

第5行:未定义对boost :: timer :: auto_cpu_timer :: auto_cpu_timer(short)的引用'

第6行:对boost :: timer :: auto_cpu_timer :: ~~ auto_cpu_timer()的未定义引用'

如果我使用标头 boost / thread.hpp ,但用于线程构造函数/析构函数。
但是例如 boost / shared_ptr 可以毫无问题地进行编译。
neatbeans中的结果编译命令为

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

我错过了什么?

推荐答案

您需要针对boost_timer进行链接。将 -lboost_timer 添加到gcc命令行。有关如何将库添加到项目,请查阅Netbeans文档。

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.

这篇关于对boost :: timer :: auto_cpu_timer的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆