missing underscore in jni function names [message #240806] |
Fri, 16 February 2007 06:16 |
Eclipse User |
|
|
|
Originally posted by: brt33004.gmx.net
Hello,
I have a set of Java classes containing native methods. The dll where
these methods are implemented was originally created using Visual Studio
6.0. Yesterday I ported the project to Eclipse using CDT. I created a new
project (Managed Make C++ Project) of the type "Shared Library (Gnu on
Windows)". Compiling works fine, a dll file is created - but it doesn't
work.
If I replace the dll created with Visual C++ by the new dll I get a
"Unsatisfied Link Error". After analysing both files (using Dependency
Walker) I noticed that the names of the functions exported by the not
working dll all start with "Java_". The names in the working dll start
with "_Java_". But the source files never contained methods with a leading
underscore. They must have been added by the compiler. Adding the
underscores manually works, but this is no solution for me because javah
produces header files without them.
Can someone explain me what works wrong?
Tom
|
|
|
Re: missing underscore in jni function names [message #240832 is a reply to message #240806] |
Sun, 18 February 2007 18:29 |
Eclipse User |
|
|
|
Originally posted by: brt33004.gmx.net
It took the whole weekend, but I found the answer to my own question:
DLL function names produced by MSVC and dcc are always different. There are
two formats allowed for JNI:
Java_package_class_method and
_Java_package_class_method@x
(where x is the number of bytes in the argument list)
Byt by default gcc produces function names of the format
Java_package_class_method@x. To change this, the linker flag -Wl,--kill-at
mut be added (Project Settings->C/C++ Build->Tool Settings->GCC C++
Linker->Miscellaneous->Linker Flags). This causes the @x not to be added.
|
|
|
Powered by
FUDForum. Page generated in 0.02579 seconds