Help with gcc and JNI

uaimp

Registered
Hello

I am trying to create a dynamic library function which creates a JavaVM and makes calls to an API written in Java. I am trying to compile the C program for this and a test harness written in C.
I get the following errors:

gcc -bundle -o libcdll.dylib *.c -framework JavaVM -I/System/Library/Frameworks/JavaVM.framework/Headers

gcc -o TestHarn Testharn.c -L. -lcdll -framework JavaVM

I get the following error:

ld: libcdll.dylib is input for dynamic link editor, is not relocatable by the static link editor.

I am new to MacOS and using version 10.2. Can anyone out there help me.
 
It looks like you're creating a dynamic library and are trying to link it as if it was static. Try this (note, this is off the top of my head and may not be exactly perfect) ---

gcc -c *.c -framework JavaVM -I/System/Library/Frameworks/JavaVM.framework/Headers

ar cr mylibrary.a *.o
ranlib mylibrary.a

gcc -o TestHarn Testharn.c -L. -lmylibrary -framework JavaVM
 
Back
Top