我想将一个linux GUI程序移植到窗口。 但在我这样做之前,我试图将一个python“hello_world”脚本移植到c代码然后编译c do to exe
以下是我如何使用Windows 7上的cython将python代码移植到c
cython --embed -o hello.c hello.py
现在我尝试在开发人员命令提示符上使用Visual Studio中的cl编译器以及Windows 命令提示符编译C代码,如下所示
cl /IC:\Python27\include\ /c hello.c /OUT hello
以上制作hello.obj
文件
现在连接部分看起来有点痛苦。这是我如何链接
cl hello.obj -LIBPATH C:\Python27\libs\* /MACHINE:X64
但我在下面遇到以下错误
/out:hello.exe
hello.obj
C:\Python27\libs\bz2.lib
C:\Python27\libs\libpython27.a
C:\Python27\libs\pyexpat.lib
C:\Python27\libs\python27.lib
C:\Python27\libs\select.lib
C:\Python27\libs\unicodedata.lib
C:\Python27\libs\winsound.lib
C:\Python27\libs\_bsddb.lib
C:\Python27\libs\_ctypes.lib
C:\Python27\libs\_ctypes_test.lib
C:\Python27\libs\_elementtree.lib
C:\Python27\libs\_hashlib.lib
C:\Python27\libs\_msi.lib
C:\Python27\libs\_multiprocessing.lib
C:\Python27\libs\_socket.lib
C:\Python27\libs\_sqlite3.lib
C:\Python27\libs\_ssl.lib
C:\Python27\libs\_testcapi.lib
C:\Python27\libs\_tkinter.lib
Creating library hello.lib and object hello.exp
hello.obj : error LNK2019: unresolved external symbol __imp__PyMem_Malloc refere
nced in function ___pyx_insert_code_object
hello.obj : error LNK2019: unresolved external symbol __imp__PyMem_Realloc refer
enced in function ___pyx_insert_code_object
hello.obj : error LNK2019: unresolved external symbol __imp__PyObject_SetAttrStr
ing referenced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyUnicodeUCS2_FromS
tringAndSize referenced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyUnicodeUCS2_Decod
eUTF8 referenced in function ___Pyx_InitStrings
hello.obj : error LNK2019: unresolved external symbol __imp__PyString_FromString
AndSize referenced in function ___Pyx_InitStrings
hello.obj : error LNK2019: unresolved external symbol __imp__PyString_FromString
referenced in function ___Pyx_CreateCodeObjectForTraceback
hello.obj : error LNK2019: unresolved external symbol __imp__PyString_FromFormat
referenced in function ___Pyx_CreateCodeObjectForTraceback
hello.obj : error LNK2019: unresolved external symbol __imp__PyString_Size refer
enced in function ___Pyx_Print
hello.obj : error LNK2019: unresolved external symbol __imp__PyString_AsString r
eferenced in function ___Pyx_Print
hello.obj : error LNK2019: unresolved external symbol __imp__PyString_InternFrom
String referenced in function ___Pyx_InitStrings
hello.obj : error LNK2019: unresolved external symbol __imp__PyTuple_New referen
ced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyDict_New referenc
ed in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyDict_SetItem refe
renced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyModule_GetDict re
ferenced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyFile_WriteObject
referenced in function ___Pyx_Print
hello.obj : error LNK2019: unresolved external symbol __imp__PyFile_SoftSpace re
ferenced in function ___Pyx_Print
hello.obj : error LNK2019: unresolved external symbol __imp__PyFile_WriteString
referenced in function ___Pyx_Print
hello.obj : error LNK2019: unresolved external symbol __imp__PyTraceBack_Here re
ferenced in function ___Pyx_AddTraceback
hello.obj : error LNK2019: unresolved external symbol __imp__PyErr_WarnEx refere
nced in function ___Pyx_check_binary_version
hello.obj : error LNK2019: unresolved external symbol __imp__PyErr_SetString ref
erenced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyErr_Occurred refe
renced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyErr_Clear referen
ced in function _main
hello.obj : error LNK2019: unresolved external symbol __imp__PyOS_snprintf refer
enced in function ___Pyx_check_binary_version
hello.obj : error LNK2019: unresolved external symbol __imp__Py_InitModule4 refe
renced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__Py_SetProgramName r
eferenced in function _main
hello.obj : error LNK2019: unresolved external symbol __imp__Py_Initialize refer
enced in function _main
hello.obj : error LNK2019: unresolved external symbol __imp__Py_Finalize referen
ced in function _main
hello.obj : error LNK2019: unresolved external symbol __imp__PyErr_Print referen
ced in function _main
hello.obj : error LNK2019: unresolved external symbol __imp__Py_GetVersion refer
enced in function ___Pyx_check_binary_version
hello.obj : error LNK2019: unresolved external symbol __imp__Py_FlushLine refere
nced in function _main
hello.obj : error LNK2019: unresolved external symbol __imp__PySys_GetObject ref
erenced in function ___Pyx_GetStdout
hello.obj : error LNK2019: unresolved external symbol __imp__PySys_SetArgv refer
enced in function _main
hello.obj : error LNK2019: unresolved external symbol __imp__PyImport_AddModule
referenced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyCode_New referenc
ed in function ___Pyx_CreateCodeObjectForTraceback
hello.obj : error LNK2019: unresolved external symbol __imp__PyFrame_New referen
ced in function ___Pyx_AddTraceback
hello.obj : error LNK2019: unresolved external symbol __imp__PyExc_ImportError r
eferenced in function _initpy
hello.obj : error LNK2019: unresolved external symbol __imp__PyExc_RuntimeError
referenced in function ___Pyx_GetStdout
hello.obj : error LNK2019: unresolved external symbol __imp___PyThreadState_Curr
ent referenced in function ___Pyx_AddTraceback
C:\Python27\libs\bz2.lib : warning LNK4272: library machine type 'x64' conflicts
with target machine type 'X86'
C:\Python27\libs\libpython27.a : warning LNK4272: library machine type 'x64' con
flicts with target machine type 'X86'
C:\Python27\libs\pyexpat.lib : warning LNK4272: library machine type 'x64' confl
icts with target machine type 'X86'
C:\Python27\libs\python27.lib : warning LNK4272: library machine type 'x64' conf
licts with target machine type 'X86'
C:\Python27\libs\select.lib : warning LNK4272: library machine type 'x64' confli
cts with target machine type 'X86'
C:\Python27\libs\unicodedata.lib : warning LNK4272: library machine type 'x64' c
onflicts with target machine type 'X86'
C:\Python27\libs\winsound.lib : warning LNK4272: library machine type 'x64' conf
licts with target machine type 'X86'
C:\Python27\libs\_bsddb.lib : warning LNK4272: library machine type 'x64' confli
cts with target machine type 'X86'
C:\Python27\libs\_ctypes.lib : warning LNK4272: library machine type 'x64' confl
icts with target machine type 'X86'
C:\Python27\libs\_ctypes_test.lib : warning LNK4272: library machine type 'x64'
conflicts with target machine type 'X86'
C:\Python27\libs\_elementtree.lib : warning LNK4272: library machine type 'x64'
conflicts with target machine type 'X86'
C:\Python27\libs\_hashlib.lib : warning LNK4272: library machine type 'x64' conf
licts with target machine type 'X86'
C:\Python27\libs\_msi.lib : warning LNK4272: library machine type 'x64' conflict
s with target machine type 'X86'
C:\Python27\libs\_multiprocessing.lib : warning LNK4272: library machine type 'x
64' conflicts with target machine type 'X86'
C:\Python27\libs\_socket.lib : warning LNK4272: library machine type 'x64' confl
icts with target machine type 'X86'
C:\Python27\libs\_sqlite3.lib : warning LNK4272: library machine type 'x64' conf
licts with target machine type 'X86'
C:\Python27\libs\_ssl.lib : warning LNK4272: library machine type 'x64' conflict
s with target machine type 'X86'
C:\Python27\libs\_testcapi.lib : warning LNK4272: library machine type 'x64' con
flicts with target machine type 'X86'
C:\Python27\libs\_tkinter.lib : warning LNK4272: library machine type 'x64' conf
licts with target machine type 'X86'
hello.exe : fatal error LNK1120: 39 unresolved externals
请原谅我对C语言某些方面的无知。
如何从hello.c创建一个.exe,它是从Windows 7上的cython生成的?