LNK2001:我的boost库(可能)构建不正确

Xir*_*ema 7 c++ boost visual-studio lnk2001

我决定将我的boost库从1.61更新到1.63,在我更新的项目中使用新文件,我收到一些我以前没有得到的新错误消息:

error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ)
error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ)
Run Code Online (Sandbox Code Playgroud)

由于我的1.63库是使用Visual Studio 2017编译的,我的第一个假设是我在编译boost库时犯了一个错误,所以这里是我从boost文件的一个干净解压缩中得到的总步骤:

  1. 开始菜单→Visual Studio 2017 RC→开发人员命令提示符
  2. 我更改目录,直到我在高级boost_1_63_0文件夹中.
  3. 我跑 bootstrap.bat
  4. 我打开project-config.jam进行编辑
  5. using msvc ;改为using msvc : 14.1 : E:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.10.24911\bin\HostX64\x64\;
  6. 我打开boost/config/auto_link.hpp进行编辑
  7. 我对此文件进行了编辑(列表后面列出的代码)
  8. 在打开命令提示符下,我执行命令 b2 architecture=x86 address-model=64 link=static threading=multi runtime-link=shared --build-type=complete stage --stagedir=stage/x64 -a
  9. 它在最后以下面的消息完成(在列表后面列出)
  10. 我尝试将这些库与我的代码一起使用,#define BOOST_LIB_DIAGNOSTIC用于跟踪正在使用的文件(它们是).
  11. 我尝试编译使用boost.asio的项目,并获得上面列出的两个未解决的外部符号错误.

有谁知道我的错误在哪里?如果我使用在Visual Studio 2017 RC中使用Visual Studio 2015编译的boost 1.61库,则不会发生这些错误.

auto_link.hpp(旧):

# elif defined (BOOST_MSVC)

     // vc14:
#  define BOOST_LIB_TOOLSET "vc140"
Run Code Online (Sandbox Code Playgroud)

auto_link.hpp(新):

# elif defined (BOOST_MSVC) && (BOOST_MSVC < 1910)

     // vc14:
#  define BOOST_LIB_TOOLSET "vc140"

# elif defined (BOOST_MSVC)

     // vc15:
#  define BOOST_LIB_TOOLSET "vc141"
Run Code Online (Sandbox Code Playgroud)

boost编译过程结束时的消息:

...failed updating 6 targets...
...skipped 4 targets...
...updated 904 targets...
Run Code Online (Sandbox Code Playgroud)

显示的图书馆使用#define BOOST_LIB_DIAGNOSTIC:

1>Linking to lib file: libboost_system-vc141-mt-1_63.lib
1>Linking to lib file: libboost_date_time-vc141-mt-1_63.lib
1>Linking to lib file: libboost_regex-vc141-mt-1_63.lib
Run Code Online (Sandbox Code Playgroud)

如果需要任何其他诊断信息,请告诉我.我尝试评论boost.asio库的各种用途,但只删除标题完全消除了这些问题(当然,这使得boost组件无法使用).

JHB*_*ius 5

这似乎与使用Boost :: asio的LNK 2019错误类似,因为您有相同的错误.

我刚刚安装了VS2017RC并提升了1.63.然后我使用了这个描述:用msvc 14.1(VS2017 RC)构建boost .注意:你的行

using msvc : 14.1 : E:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.10.24911\bin\HostX64\x64\;
Run Code Online (Sandbox Code Playgroud)

应该包括"cl.exe"和引号.

using msvc : 14.1 : "E:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.10.24911\bin\HostX64\x64\cl.exe";
Run Code Online (Sandbox Code Playgroud)

......他们应该实施进度条等;)猜猜:

...failed updating 6 targets...
...skipped 4 targets...
...updated 1214 targets...
Run Code Online (Sandbox Code Playgroud)

所以看一下错误信息:

msvc.compile.asm bin.v2\libs\context\build\msvc-14.1\debug\address-model-64\link-static\threading-multi\asm\make_x86_64_ms_pe_masm.obj
'ml64' is not recognized as an internal or external command, operable program or batch file.
ml64 -nologo -c -Zp4 -Cp -Cx -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_EXPORT= -DBOOST_CONTEXT_SOURCE -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_EXPORT= -DBOOST_CONTEXT_SOURCE /Zi /Zd /W3  -Fo "bin.v2\libs\context\build\msvc-14.1\debug\address-model-64\link-static\threading-multi\asm\make_x86_64_ms_pe_masm.obj" "libs\context\src\asm\make_x86_64_ms_pe_masm.asm"
...failed msvc.compile.asm bin.v2\libs\context\build\msvc-14.1\debug\address-model-64\link-static\threading-multi\asm\make_x86_64_ms_pe_masm.obj...
Run Code Online (Sandbox Code Playgroud)

缺少64位依赖...所以,就像KindDragon在第二个链接中所说:

从Windows开始菜单运行"VS 2017 RC的开发人员命令提示符",从使用x86 vcvars或x64 vcvars配置的shell进行boostrap.

必须使用64位编译器变量配置shell.

cd "\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
vcvarsall amd64
Run Code Online (Sandbox Code Playgroud)

..或者,您可以从"开始"菜单启动x64本机环境: -> Visual Studio 201x -> Visual Studio Tools -> Windows Desktop Command Prompts -> VS201x x64 Native Tools Command Prompt

然后重新构建.

...failed updating 2 targets...
...skipped 2 targets...
...updated 6 targets...
Run Code Online (Sandbox Code Playgroud)

有错误消息fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'.因此需要重建.

b2 --clean-all
etc...
Run Code Online (Sandbox Code Playgroud)

......你明白了.但似乎我现在在博格丹也提到这一点的评论中读到了这一点.好吧,Kinddragon in Build boost with msvc 14.1(VS2017 RC)实际上是第一个;)