User forums > Using Code::Blocks
Compiling a JNI file in Dev-C++ and Code::Blocks
kostyabkg:
int i;
for (i = 0; i < 100; i++)
{
printf("Thank you!\n");
}
:D
Yes, it's important to get it working with GNU GCC, because I also want to produce .so files for other systems, than MS Windows. If a Java program loses its' interoperability, then what Java is for???
kostyabkg:
I have noticed that "def" files are different if it can help anyhow...
Michael:
Hello,
Yesterday night, I have worked to try solve this problem. Interesting challenge :). The problem of the java exception is not IMHO a C::B bug.
Several users have had such issue. Just look at here for descriptions and solutions (which could work or not :?):
http://forum.java.sun.com/thread.jspa?threadID=570194&tstart=29
The problem is that the GNU GCC generates a not correct def file. Therefore, the DLL is not create correctly. As a consequence, Java loads the library, but the method cannot be found (bad signature, I think). This generates the UnsatisfiedLinkError.
Instead MS Toolkit 2003 and (I have read) Borland compiler create a valid DLL (and a valid def/exp file).
In the Java thread mentioned above, a user suggests:
--- Quote ---GOTCHA: I found the option to solve the compiling problem with MinGW gcc. Use this command line:
gcc -shared -o bridgeC.dll bridgeC.o bridgeC.def
Inside the .def file, only describe the right function name:
--- bridgeC.def ----
EXPORT
sayHelloWorld
--- bridgeC.def ----
The compiler will say something like: Warning: linking sayHelloWorld to sayHelloWorld@2 , but the DLL will work.
--- End quote ---
This solution worked for me too, but only if I call gcc directly by using a command dos window. By using C::B, it did not work. I suppose that I could not configure C::B correctly or I have missed something. I have tried with C::B RC2 and SVN rev1447 with no positive results. I have also used MinGW that come with the release of C::B and another that I have installed with MSYS. Same result.
May be it could be possible to use a makefile, but I did not try it (sorry, but I am not a makefile expert :oops:).
You can try to look at wich compiler/link options use Dev-C++ and import them in C::B. You can also try the same MinGW that Dev-C++ uses.
Best wishes,
Michael
jschwarz0:
sorry I don't have this setup to try
from this link: http://forum.java.sun.com/thread.jspa?threadID=470937&messageID=2414695
you should be able to add:
--add-stdcall-alias to your gcc options
or
wrap all jni available calls with
extern C
jim
Michael:
--- Quote from: jschwarz0 on December 09, 2005, 12:22:37 am ---you should be able to add:
--add-stdcall-alias to your gcc options
--- End quote ---
I have already tried this option, but it did not work (at least for me)
--- Quote from: jschwarz0 on December 09, 2005, 12:22:37 am ---or
wrap all jni available calls with
extern C
jim
--- End quote ---
I will give it a try, thanks.
Michael
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version