使用MINGW构建JNI DLL [英] Build a JNI DLL using MINGW
问题描述
我正在尝试创建一个将调用Qt的DLL(当前,我无法使用Jambi来实现所需的功能).我有一个简单的Java方法:
I am trying to create a DLL that will call Qt (currently I can't use Jambi for the functionality I need). I have a simple Java method:
public final native int createChild(int handle);
我在Visual Studio Express 2010中创建了C项目,并且能够构建DLL.
I created C project in Visual Studio Express 2010 and was able to build the DLL.
然后,我在Qt Creator中创建了一个项目,并将我的源代码移到了那里.我尝试尽我所能配置该版本,但我得到的只是:
Then I created a project in Qt creator and moved my sources there. I tried to configure the build to a best of my knowledge but all I get is:
java.lang.UnsatisfiedLinkError: tools.proofofconcept.control.EmbedderComposite.createChild(I)I
我的猜测是该符号未从DLL中正确导出.我添加了-D_JNI_IMPLEMENTATION_链接器arg:
My guess is that symbol is not properly exported from DLL. I added -D_JNI_IMPLEMENTATION_ linker arg:
g++ -D_JNI_IMPLEMENTATION_ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -shared -mthreads -Wl -Wl,--out-implib,debug\libqt_integration.a -o debug\qt_integration.dll debug/dllmain.o debug/nativecode.o debug/qmfcapp.o debug/qwinwidget.o debug/moc_qwinwidget.o -L"c:\Qt\2010.05-rc1\qt\lib" -lQtGuid4 -lQtCored4
推荐答案
我应该添加以下参数:
-Wl,--kill-at
它将更改导出的符号格式.
It will change exported symbols format.
这篇关于使用MINGW构建JNI DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!