Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: UnsatisfiedLinkError after building a JNI Library
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UnsatisfiedLinkError after building a JNI Library

Miguel Muñoz wrote:

miguel-munozs-mac-pro:Piddy miguel$ java Piddy

What version of Java will be run for that command-line?

Post the output of:
  java -version

If it runs Java 6, then that will not be compatible with this:

libPiddy.jnilib: Mach-O dynamically linked shared library i386

because Java 6 is 64-bit only, and the compiled JNI-lib is 32-bit only (the i386 arch-name is 32-bit Intel).

If you are running Java 6, or 64-bit Java 5, then you must compile your JNI lib for the correct architecture.

gcc -x c \
  -arch x86_64 \
  -I/System/Library/Frameworks/JavaVM.framework/Headers \
  -c Piddy.c -o Piddy.o

The 'gcc -dynamiclib ...' command-line will also need the -arch x86_64 option added.

You can confirm the compiled jnilib is 64-bit using:
  file libPiddy.jnilib

and looking for the x86_64 arch.

If you intend to use your jnilib on multiple architectures, you will have to compile it as a fat mach-o (Universal Binary). Exactly how to do that depends on what your tool chain is. If you want specific advice, you'll have to describe exactly what you're using: be specific. I can't tell from your original post whether you're using a manual command-line, a makefile, IntelliJ, or something else in the actual production.

  -- GG

Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.