Cal
Cal

Reputation: 1635

JNI error on Mac OS X 10.4.11... dyld: Symbol not found: _objc_setProperty

I have a problem with some JNI code. I'm getting the following error printed in the console from a OS X 10.4.11 (PPC) machine (it works fine on newer versions of OS X 10.5+)

dyld: lazy symbol binding failed: Symbol not found: _objc_setProperty
  Referenced from: /Path/to/my/lib/libMylib32.jnilib
  Expected in: /usr/lib/libobjc.A.dylib

dyld: Symbol not found: _objc_setProperty
  Referenced from: /Path/to/my/lib/libMylib32.jnilib
  Expected in: /usr/lib/libobjc.A.dylib

I have another jnilib which works fine that runs before this one in the program. The error seems to be saying I'm missing some core objective c "stuff". The other jnilib which is working on 10.4.11 uses just 1 .m file and doesn't use objective c properties (it uses NSMutableArray, NSDictionary, CFPreferences and so on). The one which doesn't work on 10.4.11 is more complex makes use of some objective c classes with properites I wrote.

Maybe I'm not compiling my code correctly or maybe properties aren't supported?

I have a shell script which compiles the jnilib. It's practically the same as the one which works as far as I can tell. I have another section for compiling the 64 bit jnilib above this in the script but the 32 bit one is being used for 10.4.11.

COCOA_HEADERS=/System/Library/Frameworks/Cocoa.framework/Headers
BITS=32
JAVA_HEADERS=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Headers
MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk
CFLAGS="-fPIC -arch i386 -arch ppc"
LIB_NAME=${LIB_PREFIX}${BITS}.jnilib
MAC_LIB_OUTPUT=/path/to/my/output/folder/${LIB_NAME}
DYLIB_ARCH="-arch i386 -arch ppc"

rm *.o
#Compile for 1.5 32bit Java
gcc -v -std=gnu99 -c ${CFLAGS} -isysroot ${MAC_SDK} -I${JAVA_HEADERS} -I${COCOA_HEADERS} ${SOURCE_FILES}
# Make the library file from the object files (*.o)
gcc -v -dynamiclib -o ${MAC_LIB_OUTPUT} *.o  -framework JavaVM -framework Cocoa ${DYLIB_ARCH}

I appreciate your answers and ideas on how to debug this one. Thanks!

Upvotes: 0

Views: 1381

Answers (2)

mmmmmm
mmmmmm

Reputation: 32700

Properties are a new Objective-C 2 feature Apple site and that only runs on OSX 10.5 and above. Thus I suspect the C code will only run on 10.5

You will have to write the C code targeting older versions of OSX. For details see Apple docs This includes non Xcode ways

Upvotes: 1

Peter Hosey
Peter Hosey

Reputation: 96363

Use Xcode. It supports Java, and it's designed to handle things like supporting old versions of Mac OS X. In Xcode, you would set your SDKROOT to macosx10.4u (Mac OS X, 10.4 with universal binary support) and MACOSX_DEPLOYMENT_TARGET to 10.4, and Xcode will tell the linker where to get the right versions of the frameworks.

If you insist on building with a shell script, then you'll need to do that yourself. You're currently using the system versions.

Upvotes: 1

Related Questions