LNK2001:(可能)我的boost库构建不正确 [英] LNK2001: My boost libraries are (probably) built incorrectly

查看:211
本文介绍了LNK2001:(可能)我的boost库构建不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I decided to update my boost libraries from 1.61 to 1.63, and in the project that I updated to use the new files, I'm getting some new error messages I wasn't getting before:

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)

由于我的1.63库是使用Visual Studio 2017编译的,因此我的第一个假设是,我在编译Boost库时犯了一个错误,因此,这是我从干净的Boost文件的纯压缩文件中采取的全部步骤:

Since my 1.63 libraries are being compiled using Visual Studio 2017, my first assumption is that I've made a mistake compiling the boost libraries, so here are the total steps I'm taking from a clean unzip of the boost files:

  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的项目,并得到上面列出的两个未解决的外部符号错误.
  1. Start Menu→Visual Studio 2017 RC→Developer Command Prompt
  2. I change directory until I'm in the high-level boost_1_63_0 folder.
  3. I run bootstrap.bat
  4. I open project-config.jam for editing
  5. I change using msvc ; to using msvc : 14.1 : E:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.10.24911\bin\HostX64\x64\;
  6. I open boost/config/auto_link.hpp for editing
  7. I make an edit to this file (code listed below after the list)
  8. In the open command prompt, I execute the command b2 architecture=x86 address-model=64 link=static threading=multi runtime-link=shared --build-type=complete stage --stagedir=stage/x64 -a
  9. It completes with the following message at the end (listed below after the list)
  10. I attempt to use these libraries with my code, using #define BOOST_LIB_DIAGNOSTIC to track that the correct files are being used (they are).
  11. I attempt to compile my project that uses boost.asio, and get the two unresolved external symbol errors listed above.

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

Does anyone know where my mistake is? These errors do not occur if I use the boost 1.61 libraries compiled using Visual Studio 2015 in Visual Studio 2017 RC.

auto_link.hpp(旧):

auto_link.hpp (old):

# elif defined (BOOST_MSVC)

     // vc14:
#  define BOOST_LIB_TOOLSET "vc140"

auto_link.hpp(新):

auto_link.hpp (new):

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

     // vc14:
#  define BOOST_LIB_TOOLSET "vc140"

# elif defined (BOOST_MSVC)

     // vc15:
#  define BOOST_LIB_TOOLSET "vc141"

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

Message at the end of the boost compilation process:

...failed updating 6 targets...
...skipped 4 targets...
...updated 904 targets...

使用#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

让我知道是否还需要其他诊断信息.我尝试注释掉boost.asio库的各种用法,但是只删除了标头就完全消除了这些问题(当然,这些问题使boost组件无法使用).

Let me know if there's any other diagnostic information needed. I tried commenting out various uses of the boost.asio library, but only removing the header entirely eliminated these issues (which, of course, made the boost components unusable).

推荐答案

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

This seems to be similar as LNK 2019 error using Boost::asio as you have the same errors.

我刚刚安装了VS2017RC并提升了1.63.然后我使用了以下描述:使用msvc 14.1(VS2017 RC)构建增强功能 .注意:您的行

I just installed VS2017RC and boost 1.63. Then I used this description: Build boost with msvc 14.1 ( VS2017 RC) . Note: your line

using msvc : 14.1 : E:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.10.24911\bin\HostX64\x64\;

可能应该包含"cl.exe"和引号.

should probably include the "cl.exe" and quotes.

using msvc : 14.1 : "E:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.10.24911\bin\HostX64\x64\cl.exe";

...他们应该实现进度条等;) 猜猜是什么

...They should implement a progress bar or such ;) Guess what:

...failed updating 6 targets...
...skipped 4 targets...
...updated 1214 targets...

因此,请查看错误消息:

So look at the error message:

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...

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

Missing 64-bit dependencies... So, like KindDragon says in the second link:

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

Run "Developer Command Prompt for VS 2017 RC" from Windows Start Menu to boostrap from a shell configured using the x86 vcvars or x64 vcvars.

有必要使用64位编译器变量来配置Shell.

It is necessary to configure the shell using the 64-bit compiler variables.

cd "\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
vcvarsall amd64

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

..alternatively you could start the x64 native environment from the Start menu: -> 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...

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

With error message fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'. So a rebuild is required.

b2 --clean-all
etc...

...您明白了.但似乎我现在在评论中读到博格丹也提到了这一点.好吧,使用msvc 14.1(VS2017 RC)构建增强功能的Kinddragon 实际上是第一个;)

...You get the point. But it seems I read now in the comments that Bogdan has also mentioned this. Well, Kinddragon in Build boost with msvc 14.1 ( VS2017 RC) was actually first ;)

这篇关于LNK2001:(可能)我的boost库构建不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆