g ++:如何取消导出的符号 [英] g++: How to unmangle exported symbols

查看:488
本文介绍了g ++:如何取消导出的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译一个使用JNI的Java库。当我启动程序时,我看到一个UnsatisfiedLinkError崩溃,它说DLL中找不到特定的方法。

I'm trying to compile a Java library that uses JNI. When I start the program, I see a crash with an UnsatisfiedLinkError, which says that a particular method could not be found in the DLL.

仔细检查后,我发现我用于编译和链接的g ++通过向方法名称添加后缀(如@ 8或@ 16)来改变我的方法名称。有没有人知道正确的编译器选项来禁用名称修改?提前感谢!

On closer inspection, I found out that g++, which I use for compilation and linking, mangled my method names by adding suffixes such as "@8" or "@16" to the method names. Does anybody know the correct compiler options to disable the name mangling? Thanks in advance!

编辑:我通过Eclipse + CDT插件使用MinGW。

EDIT: I'm using MinGW through Eclipse + CDT plugin.

推荐答案

对于使用GCC编译的Windows DLL的JNI调用,您需要在链接阶段向GCC添加add-stdcall-alias参数:

For JNI calls to work with Windows DLLs compiled with GCC you need to add a add-stdcall-alias parameter to GCC on linking phase:

gcc -Wl,--add-stdcall-alias

这将为DLL添加正确的函数名称,从而通过JNI启用调用。

Which will add correct function names to the DLL and thus enable calls via JNI.

这篇关于g ++:如何取消导出的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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