I am trying to compile a .c
file create by Cython to a .pyd
file using cl.exe
, which comes with the Microsoft Windows SDK.
Since this is the recommended package to build Cython under Windows 7 64 bit for Python 2.7 64 bit, I thought it would be a good idea to use the same compiler to create the .pyd
files.
My current call uses a cythoncc.bat
file with:
set CLPATH="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\cl.exe"
SET INCLUDE="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include";"C:\Program Files\Microsoft SDKs\Windows\v7.0\Include";"C:\Python27\include";"C:\Python27\Lib\site-packages\numpy\core\include";
SET LIB="C:\Python27\libs";"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\amd64";"C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib\x64";
SET CFLAGS="/O2 /favor:<INTEL64>"
%CLPATH% %CFLAGS% /Fo%1.pyd %2.c
I think the problem is in the last line, but not sure yet... it gives me the error:
/out:_conecyl.exe
_conecyl.pyd
Creating library _conecyl.lib and object _conecyl.exp
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced
in function __tmainCRTStartup
_conecyl.exe : fatal error LNK1120: 1 unresolved externals
And creates a .pyd
plus a .lib
file.
Any help will be very appreciated! Thank you!
Use the setup.py
recipe explained in the documentation and here
EDIT by Saullo:
the setup.py
looked just like this:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("_conecyl", ["_conecyl.pyx"])]
setup(
name = '_conecyl',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
And with the following calls it worked just perfect:
setenv /x64 / release
set INCLUDE=%INCLUDE%;C:\Python27\include;C:\Python27\Lib\site-packages\numpy\core\include
set LIB=%LIB%;C:\Python27\libs
set DISTUTILS_USE_SDK=1
python setup.py install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With