如何使用VS C++ 6.0在Python C++应用程序中嵌入Python 2.4?

A.R*_*.R. 3 c++ python visual-c++ visual-studio-6

我使用Python 2.4和MS VC++ 6得到了这个链接错误:

Linking...
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__Py_Finalize
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyErr_Occurred
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyErr_Print
testPyEmb.obj : error LNK2001: unresolved external symbol _printf
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyInt_AsLong
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyObject_CallObject
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyTuple_SetItem
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyInt_FromLong
testPyEmb.obj : error LNK2001: unresolved external symbol _atoi
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyTuple_New
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyCallable_Check
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyObject_GetAttrString
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyImport_Import
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__PyString_FromString
testPyEmb.obj : error LNK2001: unresolved external symbol __imp__Py_Initialize
testPyEmb.obj : error LNK2001: unresolved external symbol _fprintf
testPyEmb.obj : error LNK2001: unresolved external symbol __iob
Run Code Online (Sandbox Code Playgroud)

将此添加到我的源文件没有帮助:

#undef _DEBUG 
Run Code Online (Sandbox Code Playgroud)

我修改了pyconfig.h以禁用调试模式并强制使用python24.lib而不是python24_d.lib,如下所示:http://tutorial.debashis.net/?p = 57&cpage = 1 仍然,同样的错误.

我能做错什么?

小智 9

既然你说要链接.lib,可能是因为你已经安装了64位版本的Python,因此链接到64位版本的.lib文件,但你的构建配置是(我怀疑) 32位 转到Configuration Manager并将其更改为64位.

希望这可以帮助.马吕斯.