I have a C program and can call it in JNI interface in Windows and Linux, but I can not make it work on (Intel based) Mac OSX 10.4 (Tiger). I`m using a makefile with the following C compiler and linker options.
In Windows the following options worked
compiler:
gcc -Wall -O3 -c -I${JAVA_HOME}\include
-I${JAVA_HOME}\include\win32
linker:
gcc -s -shared -Wl,--export-all-symbols -Wl,--kill-at
In Linux the following options worked
compiler:
gcc -Wall -O3 -c -I${JAVA_HOME}/include
-I${JAVA_HOME}/include/win32
linker:
gcc -s -shared
In Mac I`ve tried all options from above and have searched the net for the right code. With the following code the lib file is successfully created without any errors or warnings, but java still gives:
java.lang.UnsatisfiedLinkError: /Users/vertset/.chemaxon/lib/libinchi.jnilib:
at
java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
...
The last options I`ve tried:
compiler:
gcc -g -I/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Headers -c -fno-common -O2 -pipe
linker:
gcc -dynamic -fno-common -O2 -pipe -flat_namespace -undefined suppress
I`ve also tried the options worked in Windows or Linux, but mos of them is unknown by the Mac. I!ve also tried g++ instead of gcc in the linker, and cc program instead of gcc, they had the same results. On the net some forums said that setting the LD_LIBRARY_PATH could work, but it is also uneffective.
Thank you for your help.
Peter Vadasz
Java programmer
ChemAxon Ltd.
pvadasz@chemaxon.hu
In Windows the following options worked
compiler:
gcc -Wall -O3 -c -I${JAVA_HOME}\include
-I${JAVA_HOME}\include\win32
linker:
gcc -s -shared -Wl,--export-all-symbols -Wl,--kill-at
In Linux the following options worked
compiler:
gcc -Wall -O3 -c -I${JAVA_HOME}/include
-I${JAVA_HOME}/include/win32
linker:
gcc -s -shared
In Mac I`ve tried all options from above and have searched the net for the right code. With the following code the lib file is successfully created without any errors or warnings, but java still gives:
java.lang.UnsatisfiedLinkError: /Users/vertset/.chemaxon/lib/libinchi.jnilib:
at
java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
...
The last options I`ve tried:
compiler:
gcc -g -I/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Headers -c -fno-common -O2 -pipe
linker:
gcc -dynamic -fno-common -O2 -pipe -flat_namespace -undefined suppress
I`ve also tried the options worked in Windows or Linux, but mos of them is unknown by the Mac. I!ve also tried g++ instead of gcc in the linker, and cc program instead of gcc, they had the same results. On the net some forums said that setting the LD_LIBRARY_PATH could work, but it is also uneffective.
Thank you for your help.
Peter Vadasz
Java programmer
ChemAxon Ltd.
pvadasz@chemaxon.hu