Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JNI linux problems

Reply
Thread Tools

JNI linux problems

 
 
Ilghiz Ibraghimov
Guest
Posts: n/a
 
      08-28-2003
Dear All,

would you suggest me how to solve my problem!

I have SuSE Linux 7.3, j2sdk1.4 and compile one web example of JNI:

gcc -c JNIPrintWrapperImpl.cpp
ar cru libJNIPrintMessage.so JNIPrintWrapperImpl.o
export LD_LIBRARY_PATH=.
java JNIPrintMain

gives the following message error:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
/home2/ilgis/JAVA/DEITEL/2/chapters/appG/figG_01/libJNIPrintMessage.so:
/home2/ilgis/JAVA/DEITEL/2/chapters/appG/figG_01/libJNIPrintMessage.so:
ELF file's phentsize not the expected size

Thank you for your ideas!

Sincerely

Ilghiz

*************************************
public class JNIPrintMain{
public static void main( String args[] )
{ JNIPrintWrapper wrapper = new JNIPrintWrapper();
wrapper.printMessage( "Hello World\n" );
}
}
*************************************
public class JNIPrintWrapper {
static { System.loadLibrary( "JNIPrintMessage" ); }
public native void printMessage( String message );
}
*************************************
#include <iostream.h>
#include "JNIPrintWrapper.h"
JNIEXPORT void JNICALL Java_JNIPrintWrapper_printMessage
( JNIEnv * env, jobject thisObject, jstring message )
{
jboolean copied;
const char* charMessage =
env->GetStringUTFChars( message, &copied );
cout << charMessage;
env->ReleaseStringUTFChars( message, charMessage );
}
*************************************

 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      08-28-2003
On Thu, 28 Aug 2003 17:29:43 +0200, Ilghiz Ibraghimov wrote:
> I have SuSE Linux 7.3, j2sdk1.4 and compile one web example of JNI:
>
> gcc -c JNIPrintWrapperImpl.cpp
> ar cru libJNIPrintMessage.so JNIPrintWrapperImpl.o
> export LD_LIBRARY_PATH=.
> java JNIPrintMain
>
> gives the following message error:
>
> Exception in thread "main" java.lang.UnsatisfiedLinkError:


That isn't how to create a shared library.

Try this instead:

gcc -fPIC -shared JNIPrintWrapperImpl.cpp -o libJNIPrintMessage.so

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      08-28-2003
On Thu, 28 Aug 2003 17:56:19 +0200, Ilghiz Ibraghimov wrote:
> undefined symbol: __gxx_personality_v0
>
> There is no __gxx_... symbols in my code, but it is in the *.so
> library, and I cannot understand where to find it, please, help me
> once more!


Are you using gcc 3.2?

Try adding a link option to the command line:

gcc -fPIC -shared -lstdc++ JNIPrintWrapperImpl.cpp -o libJNIPrintMessage.so

See also (although I'm not sure if this is the same problem):
http://gcc.gnu.org/onlinedocs/gcc-3....a%20Exceptions

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
Reply With Quote
 
Ilghiz Ibraghimov
Guest
Posts: n/a
 
      08-28-2003
> Are you using gcc 3.2?

gcc 3.3

> Try adding a link option to the command line:
>
> gcc -fPIC -shared -lstdc++ JNIPrintWrapperImpl.cpp -o libJNIPrintMessage.so
>
> See also (although I'm not sure if this is the same problem):
> http://gcc.gnu.org/onlinedocs/gcc-3....a%20Exceptions


Thank you

Sincerely

Ilghiz

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JNI thread vs. native thread vs. JNI call bgabrhelik Java 0 09-29-2009 03:33 PM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:03 AM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:01 AM
Porting JNI Windows under JNI LINUX + Wine ? Pasturel Jean-Louis Java 5 03-03-2004 07:50 PM
IBM's JNI fails where Sun's JNI works Alex Hunsley Java 4 11-04-2003 10:34 AM



Advertisments