简体   繁体   中英

Cython with Visual C++ Compiler?

Once I've used Cython to generate a C file, how do I use the Visual C++ 2010 compiler to make an EXE?

I've tried

cython.py Temp.py
cl.exe /MD /I "%ProgramFiles%\Python 2.6\include" Temp.c /link
     /LibPath:"%ProgramFiles%\Python 2.6\libs"

but it says

LINK : fatal error LNK1561: entry point must be defined

and if I change the /MD option to /MT then I getTemp.c

LIBCMT.lib(crt0.obj) : error LNK2019:
  unresolved external symbol main referenced in function __tmainCRTStartup

By default, Cython does not generate the code for an executable, but for a Python module. For example, it generates an init<modulename>() function, but no main() . This can be changed by supplying the --embed option, as explained in Embedding Cython .

See also: Can Cython compile to an EXE? -- one answer even gives an example on how to do it using VC++.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM