简体   繁体   English

寻找VS 2010库的VisualStudio 2015链接器

[英]VisualStudio 2015 linker looking for VS 2010 library

I am trying to compile a old VS2010 project in VS2015 with boost.python 1_67_0 from 1_53 and python 35. 我正在尝试使用来自1_53和python 35的boost.python 1_67_0在VS2015中编译一个旧的VS2010项目。

Getting it compile was not too hard, just a few tweaks to include path and updating a couple of python 2 string handling to python 3. 使其编译起来并不难,只需进行一些调整即可包含路径并将几个python 2字符串处理更新为python 3。

But I am stuck on linking because the linker fails at: 但是我被困在链接上,因为链接器在以下位置失败:

LINK : fatal error LNK1104: cannot open file 'boost_python-vc100-mt-gd-1_67.lib'

Which really does not make sense because the library version should be vc140. 这真的没有意义,因为库版本应为vc140。 In the library path there does exist libboost_python35-vc140-mt-gd-x32-1_67.lib and a few others libboost_python35-vc140* options. 在库路径中确实存在libboost_python35-vc140-mt-gd-x32-1_67.lib和其他一些libboost_python35-vc140 *选项。

Where is it getting the name 'boost_python-vc100-mt-gd-1_67.lib' from? 它从哪里获得名称“ boost_python-vc100-mt-gd-1_67.lib”? (ie is this something I missed in the configuration?) (即是我在配置中错过的东西吗?)

Under Visual Studio Boost uses boost/configure/auto_link.hpp to generate the library names and add them to the linker's dependencies. 在Visual Studio中,Boost使用boost / configure / auto_link.hpp生成库名称并将其添加到链接程序的依赖项中。 One of the arguments to this bit of code is BOOST_LIB_NAME which for boost::python is defined in boost/python/detail/config.hpp. 这一段代码的参数之一是BOOST_LIB_NAME,它的boost :: python是在boost / python / detail / config.hpp中定义的。 In version 1_67_0 this is currently: 在版本1_67_0中,当前为:

#define BOOST_LIB_NAME boost_python##PY_MAJOR_VERSION##PY_MINOR_VERSION

Where the python patchlevel.h has the definitions for PY_MAJOR_VERSION and PY_MINOR_VERSION. python patchlevel.h中具有PY_MAJOR_VERSION和PY_MINOR_VERSION的定义。

This means that the library name itself does not need to explicitly added to the your Visual Studio project. 这意味着库名称本身不需要显式添加到Visual Studio项目中。 Just the path to the boost libraries directory. 只是boost库目录的路径。

For me I needed to remove any (boost) library names from: 对我来说,我需要从以下列表中删除所有(增强的)库名称:

  • Configuration Properties > Linker > Input > Additional Dependencies 配置属性>链接器>输入>其他依赖关系
  • Configuration Properties > Linker > All Options > Additional Dependencies 配置属性>链接器>所有选项>其他依赖关系

And needed to ensure that I built boost::python with the shared (dll) libraries since I would building a DLL. 并且需要确保我使用共享(dll)库构建了boost :: python,因为我将构建一个DLL。 The static libraries are libboost*.lib and the shared libraries are boost*.lib. 静态库为libboost * .lib,共享库为boost * .lib。 To force the generation of the shared libraries I used: 强制生成我使用的共享库:

C:\\dev\\boost\\boost_1_67_0> b2.exe link=shared,static --with-python -a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM