Linking to Python import library in Visual Studio 2005

て烟熏妆下的殇ゞ 提交于 2019-12-19 06:03:16

问题


I have a C++ application that has embedded Python. I'm building with Visual Studio 2005. When I try to link to python26.lib, I get a number of unresolved symbols, all of which begin with "__imp":

error LNK2019: unresolved external symbol __imp__Py_Initialize referenced in function _main

python26.lib is an import library (installed by the Python 2.6 installer). What do I have to do to resolve these symbols? They do exist in the import library (dumpbin /all shows them). Thanks.


回答1:


Looks like I was trying to link a 64-bit Python library to a 32-bit application. I wish the linker would tell me something other than "unresolved symbol." Linking to the 32-bit library fixes the problem.




回答2:


Try to include C:\WINDOWS\system32\python26.dll in your references. python26.lib contains the symbol names for the main DLL.



来源:https://stackoverflow.com/questions/658879/linking-to-python-import-library-in-visual-studio-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!