Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » missing underscore in jni function names
missing underscore in jni function names [message #240806] Fri, 16 February 2007 06:16 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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.
Previous Topic:exporting preferences
Next Topic:jsr45 SMAP post-processor
Goto Forum:
  


Current Time: Thu Apr 25 12:37:44 GMT 2024

Powered by FUDForum. Page generated in 0.02579 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top