gpt4 book ai didi

python - 为什么链接器在未在任何地方指定时寻找 python36_d.lib?

转载 作者:行者123 更新时间:2023-12-02 00:06:12 25 4
gpt4 key购买 nike

我正在编译 Python C++ extension module使用 VS 2017 和 SWIG。

扩展模块(.pyd 文件)的链接器(用于调试配置)的命令是:

/OUT:"D:\TFS\Dev\CGALSwig\cgal-swig-binding-4.x\build\build-python\CGAL\_CGAL_Kernel.pyd" /MANIFEST /NXCOMPAT /PDB:"D:/TFS/Dev/CGALSwig/cgal-swig-binding-4.x/build/build-python/CGAL/_CGAL_Kernel.pdb" /DYNAMICBASE "C:\Users\helloworld\AppData\Roaming\python\libs\python36.lib" "Debug\CGAL_Kernel_cpp.lib" "D:\TFS\Dev\CGALSwig\mpfr\lib\libmpfr-4.lib" "D:\TFS\Dev\CGALSwig\gmp\lib\libgmp-10.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"D:/TFS/Dev/CGALSwig/cgal-swig-binding-4.x/build/build-python/CGAL/Debug/CGAL_Kernel.lib" /DEBUG /DLL /MACHINE:X64 /INCREMENTAL /PGD:"D:\TFS\Dev\CGALSwig\cgal-swig-binding-4.x\build\build-python\CGAL\_CGAL_Kernel.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"_CGAL_Kernel_python.dir\Debug\_CGAL_Kernel.pyd.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"D:/TFS/Dev/CGALSwig/cgal-swig-binding-4.x/build/build-python/CGAL" /LIBPATH:"D:/TFS/Dev/CGALSwig/cgal-swig-binding-4.x/build/build-python/CGAL/Debug" /TLBID:1 

这清楚地表明依赖于 python36.lib 而不是 python36_d.lib。尽管如此,链接器仍会抛出此错误:

LNK1104 : cannot open file 'python36_d.lib'

当调试 LIB 不在链接器参数中时,为什么链接器要查找它?

最佳答案

埋藏在 Python.h 包含的头文件中的是这段代码:

#           if defined(_DEBUG)
# pragma comment(lib,"python36_d.lib")
# elif defined(Py_LIMITED_API)
# pragma comment(lib,"python3.lib")
# else
# pragma comment(lib,"python36.lib")
# endif /* _DEBUG */

如果定义了 _DEBUG,预处理器会选择 python36_d.lib 进行自动链接,即调试 MSVC 构建。

关于python - 为什么链接器在未在任何地方指定时寻找 python36_d.lib?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60522969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com