导出的函数名称不包含参数列表

发布于 2024-08-15 15:10:33 字数 561 浏览 5 评论 0原文

我正在 Eclipse 中使用 c++ 创建一个插件 DLL。

尝试加载插件时出现错误:

?CTC_Cleanup@YAXXZ not found. Function is not available in myplugin.dll

当使用 Dependency Walker 将另一个工作插件与我的插件进行比较时,我注意到另一个插件中的函数名称是:"void CTC_Cleanup(void)",启用“取消修饰 C++ 函数”=> “?CTC_Cleanup@YAXXZ”

在我的插件中,函数名称是:“CTC_Cleanup”,启用“Undecorate C++functions”没有什么区别。

我的 .h 文件中的 C++ 函数声明均用 "__declspec(dllexport)" 修饰,并使用

extern "C" {
...
...
...
}

/Kristofer包围

I'm creating a plugin DLL using c++ in Eclipse.

When trying to load the plugin I get an error:

?CTC_Cleanup@YAXXZ not found. Function is not available in myplugin.dll

When comparing another working plugin with my plugin using Dependency Walker I notice that the function name in the other plugin is: "void CTC_Cleanup(void)", enabling "Undecorate C++ functions" => "?CTC_Cleanup@YAXXZ".

In my plugin the function name is: "CTC_Cleanup", enabling "Undecorate C++ functions" makes no difference.

My C++ function declarations in the .h file are all decorated with "__declspec(dllexport)" and surrounded using

extern "C" {
...
...
...
}

/Kristofer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

花伊自在美 2024-08-22 15:10:33

它正在寻找一个损坏的名称,因此您不需要 extern“C”。

?CTC_Cleanup@YAXXZ 使用 VC++ 名称修饰来处理名为 CTC_Cleanup 的函数,该函数采用 void 并返回 void。

但是,您使用的是 g++ 3.x 或 4.x,并且 g++ 使用不兼容的不同重整方案。

使用 VC++ 构建您的库,或者弄清楚如何使 g++ 使用 VC++ 名称修饰。

It's looking for a mangled name, so you don't want extern "C".

?CTC_Cleanup@YAXXZ is using the VC++ name mangling for a function taking void and returning void named CTC_Cleanup.

However, you are using g++ 3.x or 4.x, and g++ uses a different mangling scheme that is incompatible.

Build your library using VC++, or else figure out how to make g++ use VC++ name mangling.

雨落星ぅ辰 2024-08-22 15:10:33

使用 C 链接时,参数名称(实际上是参数类型,正式名称​​实际上在这个级别上不重要)不重要;在 C 中,没有任何重载,因此函数名称本身就足够了,参数的类型并不重要。

Argument names (actually argument types, the formal names really shouldn't matter at this level) shouldn't matter using C linkage; in C, you don't have any overloading so the function name itself should be enough, the types of the arguments don't matter.

奢华的一滴泪 2024-08-22 15:10:33

删除 extern "C",然后它应该可以工作:我猜你的插件将在预期的名称下导出该函数。

Remove extern "C", then it should work: I guess your plugin will then export the function under the expected name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文