Trying JNI with NetBeans C/C++ Pack on Linux
I started to read http://www.netbeans.org/kb/55/beginning-jni-part1.html and soon realized that the article was for Windows while my main development machine is Ubuntu. OK, so it means that I don't need to install cygwin and the rest of the instructions in the article should work fine, right? (Un)fortunately, you need more than the difference in case you're a unixer (including Mac OS X). Here are what I've found during driving the course:
1. First of all, yes! you don't need to install cygwin :-)
2. "Press Ctrl - F11 to clean and build the project" doesn't work for my Linux. Shift - F11 does.
3.
4. No options for compilation. Simply don't apply -mno-cygwin -Wl,--add-stdcall-alias -shared -m32. FYI, -shared is automatically added as the project is designed for dynamic library.
5. Make sure that your output file ends with not ".dll" but ".so".
These are all except adding -fPIC option for #4 when you work on a 64-bit machine because without the option the compiler complains "/usr/bin/ld: build/Debug/GNU-Linux-x86/HelloWorldNative.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC"
To be honest, this is my first time to create a JNI project. (No wonder I "was" a Java purist ;-) As I began working on Ruby (on Rails) and Python (on Django), I came to get some interest in using other languages than Java. I think that NetBeans C/C++ Pack opens a nice possibility to develop extensions for Java beyond the language itself.
- Login or register to post comments
- Printer-friendly version
- iasandcb's blog
- 1983 reads





