我正在尝试将Python嵌入到Visual C ++ 2008应用程序中,而且我是b / b 遇到链接器问题。我已经使用源代码 下载的PCbuild文件夹中的pythoncode VC ++项目编译了一个Python源代码的DLL ,这100%没有任何警告等工作我已经在调试和发布模式下完成了这个 而没有任何问题。 当我在我的包含python_install_path \ include.Python.h时应用程序 (链接设置正确地生成.lib和.dll文件由我自己生成)它构建正常。但是,只要我尝试调用任何Python 函数(例如Py_Exit),我就会发现链接器错误,如下所示: 1> application.obj:错误LNK2031:无法生成p / invoke " extern" C" void __clrcall Py_Exit(int)" (?Py_Exit @@ $$ J0YMXH @ Z); 元数据中缺少调用约定 1> frmPythonInterface.obj:错误LNK2031:无法生成p / invoke 表示externC" void __clrcall Py_Exit(int)" (?Py_Exit @@ $$ J0YMXH @ Z); 元数据中缺少调用约定 我可能会遗漏一些东西,但我不能在Python.h中查找任何调用约定 详细信息或此文件中包含的其他标头。在我的 VC ++ DLL项目中,我已将调用约定指定为__stdcall。我知道__clrcall命名约定与VC + +中的托管代码有关,但据我所知,这就是我的知识。我应该手动定义 呼叫约定吗?或者在我的应用程序项目中是否存在设置错误? 如果有人能提供一些指导,我们将不胜感激。 谢谢 Jaco 解决方案 J0YMXH @ Z); 元数据中缺少调用约定 1> frmPythonInterface.obj:错误LNK2031:无法生成p / invoke 表示externC" void __clrcall Py_Exit(int)" (?Py_Exit @@ J0YMXH @ Z); 元数据中缺少调用约定 我是可能遗漏了一些东西,但我找不到任何调用约定 Python.h中的详细信息或此文件中包含的其他标题。在我的 VC ++ DLL项目中,我已将调用约定指定为__stdcall。我知道__clrcall命名约定与VC + +中的托管代码有关,但据我所知,这就是我的知识。我应该手动定义 呼叫约定吗?或者在我的应用程序项目中是否存在设置错误? 如果有人能提供一些指导,我们将不胜感激。 谢谢 Jaco Jaco Naude写道: 1> application.obj:错误LNK2031:无法生成p / invoke " extern" C" void __clrcall Py_Exit(int)" (?Py_Exit @@ Hi there,This is my first post over here and I hope someone can give me someguidance.I''m trying to embed Python into a Visual C++ 2008 application and I''mgetting linker problems. I''ve compiled a DLL of the Python source codeusing the pythoncode VC++ project in the PCbuild folder of the sourcedownload and this works 100% without any warnings etc. I''ve done thisin Debug and Release mode without any problems.When I include python_install_path\include\Python.h in my application(with the linking setup correctly to the .lib and .dll files generatedby myself) it builds fine. However as soon as I try to call any Pythonfunction (Py_Exit for example) I get linker errors as shown below:1>application.obj : error LNK2031: unable to generate p/invoke for"extern "C" void __clrcall Py_Exit(int)" (?Py_Exit@@$$J0YMXH@Z);calling convention missing in metadata1>frmPythonInterface.obj : error LNK2031: unable to generate p/invokefor "extern "C" void __clrcall Py_Exit(int)" (?Py_Exit@@$$J0YMXH@Z);calling convention missing in metadataI''m probably missing something but I can''t find any calling conventiondetails in Python.h or the other headers included in this file. In myVC++ DLL project I''ve specified the calling convention as __stdcall. Iknow the __clrcall naming convention has to do with managed code in VC++ but thats as far as my knowledge on that goes. Should I define thecalling conventions manually? Or is there a setting wrong somewhere inmy application project?If anybody can give some guidance it would be greatly appreciated.ThanksJaco 解决方案 J0YMXH@Z);calling convention missing in metadata1>frmPythonInterface.obj : error LNK2031: unable to generate p/invokefor "extern "C" void __clrcall Py_Exit(int)" (?Py_Exit@@J0YMXH@Z);calling convention missing in metadataI''m probably missing something but I can''t find any calling conventiondetails in Python.h or the other headers included in this file. In myVC++ DLL project I''ve specified the calling convention as __stdcall. Iknow the __clrcall naming convention has to do with managed code in VC++ but thats as far as my knowledge on that goes. Should I define thecalling conventions manually? Or is there a setting wrong somewhere inmy application project?If anybody can give some guidance it would be greatly appreciated.ThanksJaco Jaco Naude wrote:1>application.obj : error LNK2031: unable to generate p/invoke for"extern "C" void __clrcall Py_Exit(int)" (?Py_Exit@@ 这篇关于Python.h中未定义的调用约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-12 20:04