如何使用vsc++ 6.0在c++应用程序中嵌入Python 2.4

How to embed Python 2.4 in C++ application using VS C++ 6.0?

本文关键字:Python 应用程序 c++ vsc++ 何使用      更新时间:2023-10-16

我得到这个链接错误,使用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

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

#undef _DEBUG 

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

我做错了什么?

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

希望这对你有帮助。马吕斯。