2016-02-05 52 views
3
#include <iostream> 
#include <boost/timer/timer.hpp> 

int main() 
{ 
    boost::timer::auto_cpu_timer s; 
    std::cout << "Hello World!" << '\n'; 
    return 0; 
} 

编译此以上在QT提到代码用MSVC 12.0 x64和它引发以下错误:与升压1.60和VS 2013在x64链接错误

libboost_timer-vc120-mt-gd-1_60.lib(cpu_timer.obj) : error LNK2019: unresolved external symbol "public: static class boost::chrono::time_point<class boost::chrono::steady_clock,class boost::chrono::duration<__int64,class boost::ratio<1,1000000000> > > __cdecl boost::chrono::steady_clock::now(void)" ([email protected][email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) referenced in function "void __cdecl `anonymous namespace'::get_cpu_times(struct boost::timer::cpu_times &)" ([email protected][email protected]@[email protected]@[email protected]@@Z) 
debug\Test.exe : fatal error LNK1120: 1 unresolved externals 

升压已经在建筑x86和地址被编译模型64使用下面的命令行argument-

b2 toolset=msvc-12.0 --prefix=<location> --build-type=complete --abbreviate-paths architecture=x86 address-model=64 install -j4 

此外,当具有32位MSVC 2013编译器编译该程序运行正常,并我使用Qt创建者。这是我的项目文件的内容 -

TEMPLATE = app 
CONFIG += console c++11 
CONFIG -= app_bundle 
CONFIG -= qt 

SOURCES += main.cpp 


win32:CONFIG(release, debug|release): LIBS += "-LD:/boost/boost_1_60_0/stage/lib/" -llibboost_system-vc120-mt-1_60 -llibboost_filesystem-vc120-mt-1_60 -llibboost_timer-vc120-mt-1_60 
else:win32:CONFIG(debug, debug|release): LIBS += "-LD:/boost/boost_1_60_0/stage/lib/" -llibboost_system-vc120-mt-gd-1_60 -llibboost_filesystem-vc120-mt-gd-1_60 -llibboost_timer-vc120-mt-gd-1_60 
else:unix: LIBS += "-LD:/boost/boost_1_60_0/stage/lib/" -llibboost_system-vc120-mt-1_60 -llibboost_filesystem-vc120-mt-1_60 -llibboost_timer-vc120-mt-1_60 

INCLUDEPATH += D:/boost/boost_1_60_0/ 
+0

您没有链接(正确版本)的库。升压计时器和系统不是只有标题,也许你的项目定义发现32位库 – sehe

+0

我已经编辑了更多细节的问题。 – elvarox

+0

现在,我正在见证一个奇迹。即使我删除这些lib并包含路径,程序仍然可以在32位编译。唯一改变的是主源代码中的include行(带有boost头文件)显示在鼠标悬停时没有找到这样的文件或目录,下面有一条绿色的弯曲线。 – elvarox

回答

8

我只是恰好在VS2015同样的问题。

对我来说,解决办法是:

#include <boost/chrono.hpp> 

希望这有助于别人!

+0

它确实帮了我!投了你。 –