【问题标题】:LINK : fatal error LNK1104: cannot open file 'python38.lib' with CMake finding library链接:致命错误 LNK1104:无法使用 CMake 查找库打开文件“python38.lib”
【发布时间】:2020-04-19 20:41:03
【问题描述】:

我正在尝试将 python 库链接到 CMake 目标并从中构建模块(使用 Boost.Python3)。 CMake 正确找到 Boost.Python3 和 Python3,但是在链接时,我收到错误 LINK : fatal error LNK1104: cannot open file 'python38.lib'

我已将正确的 python38.lib 添加到我的 PATH(和 LIBPATH)中,并且 CMake 正确找到了该库:

message(STATUS "Python3_LIBRARIES = ${Python3_LIBRARIES}")

结果

-- Python3_LIBRARIES = optimized;C:/Program Files/Python38/libs/python38.lib;debug;C:/Program Files/Python38/libs/python38_d.lib

我链接了所有的库:

  target_link_libraries(trgt PRIVATE
          ${Boost_LIBRARIES}
          ${Python3_LIBRARIES}
          Python3::Python # tried with and without this line
          trgtCore)

我正在使用与我的 x64 安装的 Python 3.8 匹配的 $ cmake .. "-GVisual Studio 16 2019" -A x64 进行编译。

【问题讨论】:

    标签: python visual-c++ cmake


    【解决方案1】:

    我在从 github 安装 opencv 版本 4 时遇到了同样的问题,我通过将 .lib 文件复制到 Visual Studio 项目中解决了这个问题。

    希望对你有帮助, 阿马尔。

    【讨论】:

      【解决方案2】:

      只有在构建调试配置时才会出现同样的问题。 Release cfg 的构建没有这个问题。 调试 cfg 已正常构建,直到我安装了调试符号包。可能问题出在哪里。

      基于此讨论https://github.com/microsoft/vcpkg/issues/10649

      【讨论】:

        猜你喜欢
        • 2011-03-26
        • 1970-01-01
        • 2021-11-11
        • 2016-02-09
        • 1970-01-01
        • 2011-09-07
        • 2011-06-23
        • 2017-11-29
        • 2014-11-13
        相关资源
        最近更新 更多