2016-02-05 163 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

它確實幫了我!投了你。 –