小编elv*_*rox的帖子

在x64上与Boost 1.60和VS 2013的链接器错误

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

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

使用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
Run Code Online (Sandbox Code Playgroud)

Boost已在体系结构x86和地址模型64中编译,并带有以下命令行参数 -

b2 toolset=msvc-12.0 --prefix=<location> --build-type=complete --abbreviate-paths architecture=x86 address-model=64 install -j4
Run Code Online (Sandbox Code Playgroud)

此外,使用32位msvc 2013编译器编译时程序运行正常,我正在使用Qt Creator.这是我的项目文件的内容 -

TEMPLATE = app
CONFIG += console c++11 …
Run Code Online (Sandbox Code Playgroud)

c++ qt boost cmake

3
推荐指数
1
解决办法
917
查看次数

标签 统计

boost ×1

c++ ×1

cmake ×1

qt ×1