Python.h中未定义的调用约定 [英] Undefined calling conventions in Python.h

查看:118
本文介绍了Python.h中未定义的调用约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


这是我在这里的第一篇文章,希望有人能给我一些

的指导。

我正在尝试将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 some
guidance.

I''m trying to embed Python into a Visual C++ 2008 application and I''m
getting linker problems. I''ve compiled a DLL of the Python source code
using the pythoncode VC++ project in the PCbuild folder of the source
download and this works 100% without any warnings etc. I''ve done this
in 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 generated
by myself) it builds fine. However as soon as I try to call any Python
function (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 metadata
1>frmPythonInterface.obj : error LNK2031: unable to generate p/invoke
for "extern "C" void __clrcall Py_Exit(int)" (?Py_Exit@@$$J0YMXH@Z);
calling convention missing in metadata

I''m probably missing something but I can''t find any calling convention
details in Python.h or the other headers included in this file. In my
VC++ DLL project I''ve specified the calling convention as __stdcall. I
know 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 the
calling conventions manually? Or is there a setting wrong somewhere in
my application project?

If anybody can give some guidance it would be greatly appreciated.

Thanks
Jaco

解决方案

J0YMXH@Z);
calling convention missing in metadata
1>frmPythonInterface.obj : error LNK2031: unable to generate p/invoke
for "extern "C" void __clrcall Py_Exit(int)" (?Py_Exit@@


J0YMXH@Z);
calling convention missing in metadata

I''m probably missing something but I can''t find any calling convention
details in Python.h or the other headers included in this file. In my
VC++ DLL project I''ve specified the calling convention as __stdcall. I
know 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 the
calling conventions manually? Or is there a setting wrong somewhere in
my application project?

If anybody can give some guidance it would be greatly appreciated.

Thanks
Jaco


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中未定义的调用约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆