在Python中编译C代码的问题 [英] Problems with compiling C code in Python
问题描述
我在Windows 7(64位)中将Anaconda用于Python 2.7.10。我也使用Visual Studio2010。我安装了Microsoft Visual Studio for Python。
I use Anaconda for Python 2.7.10 in Windows 7, 64 bit. I also use Visual Studio 2010. I installed Microsoft Visual Studio for Python.
当我尝试在python中(在cmd内)编译C代码时:
When I try to compile a C code in python (inside cmd):
C:\Anaconda\sms-tools-master\software\transformations_interface>python compileModule.py build_ext --inplace
我收到很多警告和一些错误,它们的最后一部分如下:
I get a lot of warnings and some errors that the final part of it are as follows:
C:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\BIN\amd64\link.exe /DLL / nologo /INCREMENTAL:NO /LIBPATH:C:\Anaconda\libs /LIBPATH:C:\Anaconda\PCbuild\am d64 m.lib
/EXPORT:initutilFunctions_C build\temp.win-amd64-2.7\Release\utilFunct
ions.obj build\temp.win-amd64-2.7\Release\cutilFunctions.obj
/OUT:C:\Anaconda\sm
s-tools-master\software\models\utilFunctions_C\utilFunctions_C.pyd
/IMPLIB:build \temp.win-amd64-2.7\Release\utilFunctions_C.lib
/MANIFESTFILE:build\temp.win-amd
64-2.7\Release\utilFunctions_C.pyd.manifest LINK : fatal error
LNK1181: cannot open input file 'm.lib' error: command 'C:\\Program
Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\ amd64\\link.exe'
failed with exit status 1181
请让我看看如何解决此问题。
Please let me see how this problem can be fixed.
推荐答案
注释 setup.py
中的行,该行说 libraries = ['m']
,然后再次运行。
Comment the line in setup.py
that say libraries=['m']
, and run again.
链接到m的需要可能是链接Math库的GCC事情,该库由Windows环境中的MSVCR管理。
The need to link to m might be a GCC thing to link Math library, that is managed by MSVCR in Windows environment.
这篇关于在Python中编译C代码的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!