Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » missing underscore in jni function name
missing underscore in jni function name [message #184859] Fri, 16 February 2007 01:14 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 name [message #185078 is a reply to message #184859] Sun, 18 February 2007 13: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:Shortcut for bookmarks
Next Topic:Project view: how to arrange?
Goto Forum:
  


Current Time: Sat Nov 08 11:26:37 EST 2025

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

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

Back to the top