系统环境:Win10+VC2013+python35
问题描述:编译结果总是失败,跳错误提示是:fatal error LNK1104: 无法打开文件“python35.lib” 。
更换系统环境:Win10+VC2013+python27
问题描述:编译结果总是失败,跳错误提示是:fatal error LNK1104: 无法打开文件“python27.lib” ,问题依旧,故不是python版本问题。
错误的原因是系统安装有Python3.5,而默认的情况下Python是不提供python35.lib和python35_d.dll文件的。为了编译通过,需要在网上下载此二文件。通过软件everything搜索两者如下:
发现安装的软件如:Solidworks或者e2studio均包含以上文件,故将其拷贝到VC安装路径,Visual Studio12.0/VC/lib内,将下载的lib文件置于Visual Studio 12.0/VC/lib,dll文件置于Microsoft Visual Studio 12.0/VC/bin中,Release下编译通过。
Debug下,需要将 python35.lib文件复制并修改名字为python35_d.lib,具体参考如下说明。
If you build the example in debug mode, you will get an error: "cannot open file "python25_d.lib". To resolve this issue, make a copy of the existing python25.lib in your python installation "libs" folder and rename it to python25_d.lib and it will compile. You need to do this to build the debug version only. The release version will build without issues. Inspite of adding python25.lib in Additional Dependencies in the Debug configuration linker input setting, this error appears, and so I have found this workaround. It would be helpful if someone can throw some light on this issue.
本次练习的文档如下: