簡體   English   中英

在x64上與Boost 1.60和VS 2013的鏈接器錯誤

[英]Linker error with Boost 1.60 and VS 2013 on x64

#include <iostream>
#include <boost/timer/timer.hpp>

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

使用msvc 12.0 x64在qt中編譯了上面提到的代碼,它會拋出以下錯誤:

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)" (?now@steady_clock@chrono@boost@@SA?AV?$time_point@Vsteady_clock@chrono@boost@@V?$duration@_JV?$ratio@$00$0DLJKMKAA@@boost@@@23@@23@XZ) referenced in function "void __cdecl `anonymous namespace'::get_cpu_times(struct boost::timer::cpu_times &)" (?get_cpu_times@?A0x0d396f6a@@YAXAEAUcpu_times@timer@boost@@@Z)
debug\Test.exe : fatal error LNK1120: 1 unresolved externals

Boost已在體系結構x86和地址模型64中編譯,並帶有以下命令行參數 -

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

此外,使用32位msvc 2013編譯器編譯時程序運行正常,我正在使用Qt Creator。 這是我的項目文件的內容 -

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/

我在VS2015中遇到了完全相同的問題。

我的解決方案是:

#include <boost/chrono.hpp>

希望這有助於其他人!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM