【发布时间】: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