我尝试调用c库,如下例。
# demo.pyx
from libc.math cimport sin
cdef double f(double x):
return sin(x*x)
setup.py
# setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
ext_modules=[
Extension("demo",
sources=["demo.pyx"],
libraries=["m"] # Unix-like specific
)
]
setup(
name = "Demos",
ext_modules = cythonize(ext_modules)
)
运行setup.py,如下所示
%run setup.py build_ext --inplace --compiler=msvc
但是,发生以下错误:
running build_ext
building 'demo' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\ProgramData\Anaconda3\envs\tensorflow35\include -IC:\ProgramData\Anaconda3\envs\tensorflow35\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" /Tcdemo.c /Fobuild\temp.win-amd64-3.5\Release\demo.obj
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\ProgramData\Anaconda3\envs\tensorflow35\libs /LIBPATH:C:\ProgramData\Anaconda3\envs\tensorflow35\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" m.lib /EXPORT:PyInit_demo build\temp.win-amd64-3.5\Release\demo.obj /OUT:D:\etc\cython\demo.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\demo.cp35-win_amd64.lib
An exception has occurred, use %tb to see the full traceback.
SystemExit: error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1181
环境:window7,python3.5(64位),visual studio 2015社区
python路径:C:\ ProgramData \ Anaconda3 \ envs \ tensorflow35
请帮我解决这个问题。