Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » JNI: Compiled succesfull, hang on execute [3/3] "StrLen.java" (1/1)
JNI: Compiled succesfull, hang on execute [3/3] "StrLen.java" (1/1) [message #143360] Sat, 16 April 2005 15:29 Go to next message
Eclipse UserFriend
Originally posted by: MatthiasBecker.hamburg.de

Hello

i have a problem with getting JNI running.
Attached to this post are my three files. When i try to execute the java file
the programm just hangs when it comes to the System.load() command. I am not
sure whether the DLL is loaded or not.

This is my compiler command:
gcc -I"c:\java\include\win32" -O3 -Wall -c -fmessage-length=0

And this is my linker command:
dllwrap --output-def simplejni.def --add-stdcall-alias

(I found this linker part in a post earlier to this problem but so far it did
not help me.)

This is my output:
------------------------------------------------------------ -------------------------------
**** Full rebuild of configuration Release for project JNI_Test_C ****

make -k clean all
rm -rf StrLen.o StrLen.d JNI_Test_C.dll
Building file: ../StrLen.c
gcc -Ic:\java\include\win32 -O3 -Wall -c -fmessage-length=0 -oStrLen.o
.../StrLen.c
Finished building: ../StrLen.c

Building target: JNI_Test_C.dll
dllwrap --output-def simplejni.def --add-stdcall-alias -o JNI_Test_C.dll
StrLen.o
dllwrap: no export definition file provided.
Creating one, but that may not be what you want
Finished building: JNI_Test_C.dll
Build complete for project JNI_Test_C
------------------------------------------------------------ -------------------------------
Unfortunally i am not familar with the dllwrap command so i dont know what the
error "dllwrap: no export definition file provided." really means...

I am useing eclipse 3.0.2 with cdt 2.1.1. The project is a managed C project.

Thanks in advantage
Matthias

  • Attachment: StrLen.java
    (Size: 0.59KB, Downloaded 160 times)
Re: JNI: Compiled succesfull, hang on execute [3/3] "StrLen.java" (1/1) [message #143403 is a reply to message #143360] Mon, 18 April 2005 02:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daehn.hmi.de

Matthias Becker wrote:
> Hello
>
> i have a problem with getting JNI running.
> Attached to this post are my three files. When i try to execute the java file
> the programm just hangs when it comes to the System.load() command. I am not
> sure whether the DLL is loaded or not.
>

I think the problem isn't the compiler, but the class-loading in your
java file.

| from StrLen.java:
| System.load("Z:/cdt_workspace/JNI_Test_C/Release/JNI_Test_C.dll ");

this is not the normal way to load a library. The correct statement
would be:
System.load(JNI_Test_C");

this would run into a UnsatisfiedLinkError unless you've set the
LD_LIBRARY_PATH to your library, in your case:
set LD_LIBRARY_PATH=Z:/cdt_workspace/JNI_Test_C/Release/

I think with this changes your problem gets solved.

greets
Re: JNI: Compiled succesfull, hang on execute [3/3] "StrLen.java" (1/1) [message #143747 is a reply to message #143403] Wed, 20 April 2005 17:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: MatthiasBecker.hamburg.de

Chrischan <daehn@hmi.de> wrote:

No, it isnt. You can either load a library with System.loadLibrary() or with my
version. You only have to make sure that the DLL is, where you say it should be.
Anyway, i found out that it is a problem with the CDT Tool (or the
gcc-Compiler). I tried to compile the DLL with MS-Visual C++ and everything
works just fine.
Unfortunally MS-VC is really bugy and i really dont like it!

So what do i have to do to get it working with the CDT?

Thanks for the reply anyway :)

Matthias

>I think the problem isn't the compiler, but the class-loading in your
>java file.
>
>| from StrLen.java:
>| System.load("Z:/cdt_workspace/JNI_Test_C/Release/JNI_Test_C.dll ");
>
>this is not the normal way to load a library. The correct statement
>would be:
>System.load(JNI_Test_C");
>
>this would run into a UnsatisfiedLinkError unless you've set the
>LD_LIBRARY_PATH to your library, in your case:
>set LD_LIBRARY_PATH=Z:/cdt_workspace/JNI_Test_C/Release/
>
>I think with this changes your problem gets solved.
>
>greets
Re: JNI: Compiled succesfull, hang on execute [3/3] "StrLen.java" (1/1) [message #143764 is a reply to message #143747] Thu, 21 April 2005 03:35 Go to previous message
Eclipse UserFriend
Originally posted by: daehn.hmi.de

Matthias Becker wrote:
> No, it isnt. You can either load a library with System.loadLibrary() or with my
> version. You only have to make sure that the DLL is, where you say it should be.
> Anyway, i found out that it is a problem with the CDT Tool (or the
> gcc-Compiler). I tried to compile the DLL with MS-Visual C++ and everything
> works just fine.
> Unfortunally MS-VC is really bugy and i really dont like it!
>
> So what do i have to do to get it working with the CDT?
>
> Thanks for the reply anyway :)
>
> Matthias


Sorry, I didn't know about *this* fact.
Have you tried to compile your library with this command?:

gcc -shared -o JNI_Test_C.dll StrLen.o

this is the way i've done it.

greets
Previous Topic:multiple main programs in a C project
Next Topic:Amazing Indexer syntax error
Goto Forum:
  


Current Time: Thu Jul 17 23:22:15 EDT 2025

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

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

Back to the top