Question

I am helping to code a stop-motion program that is to be cross platform, and on windows it works great. For those who do not know, stop motion is just a fancy term for animation. This program allows users to plug in Nikons, Canons, and Webcams into the computer, and have the program display a live view of the scene, and then have the ability to manually control the camera from there. Included is a framework file from canon for the camera, with a path defined as shown

import com.sun.jna.Native;
initialization and such

public static EdSdkLibrary EDSDK = (EdSdkLibrary) Native.loadLibrary("Macintosh/EDSDK.framework/EDSDK",EdSdkLibrary.class, options);

The error is thrown at the "public static int..." saying that the image is not found. I have tried numerous times redefining the path, moving the framework, and using various other frameworks identical to the one I'm using. Remember, this works flawlessly on Windows, but on Mac there is a problem.

Are frameworks different on macs, or are they to be defined differently? I have looked and found no other solutions.

EDIT: Okay, I defined the path and it now has this symbol > with no text next to it. WHat do I do now?

EDIT: It is saying that this % is not a command. Without it, it still fails to work.

Était-ce utile?

La solution

JNA will successively attempt to load frameworks from ~/Library/Frameworks, /Library/Frameworks, and /System/Library/Frameworks, based on the core framework name (EDSDK in this case).

If the loadLibrary call succeeds, then the library was found. If the library was not found, you'll get an UnsatisfiedLinkError.

Frameworks are basically bundles of a shared library with other resources; ESDK.framework/ESDK is the actual shared library (for frameworks, OSX omits the "dyld" suffix normally found on a shared library on OSX).

EDIT

Here's how to make a symlink so that the paths look more like what JNA is expecting. From a terminal (run Terminal.app):

% ln -s /your/complete/path/to/Macintosh/EDSDK.framework ~/Library/Frameworks/EDSDK.framework

When this is done successfully, you should see the following when listing (ls) the symlink:

% ls -l ~/Library/Frameworks/EDSDK.framework
lrwxrwxr-x  1 YOU  YOU  50 Mar 31 01:13 /Users/YOU/Library/Frameworks/EDSDK.framework -> /your/complete/path/to/Macintosh/EDSDK/Framework/EDSDK.framework

You should see the symlink path (where JNA will look) on the left, with the path to the real file on the right. If not, delete the symlink file and try again. Note that you may need to create the directory ~/Library/Frameworks first; it may not yet exist.

Finally, make sure that the library you're trying to load matches the VM you're trying to load with; 64-bit with 64-bit, 32-bit with 32-bit. Canon does not provide a universal binary of their library, so you'll need to point to one or the other or merge the two using lipo.

Autres conseils

Not really an answer, but more information on the same problem, which I'm experiencing myself.

I can add that JNA will find my frameworks if they're in one of the standard public locations an executable looks for its frameworks, i.e.

  • ~/Library/Frameworks - (public frameworks for the use of the current user)
  • /Library/Frameworks - (public frameworks for the use of any user)
  • /System/Library/Frameworks - (public system frameworks)

However, If I want my custom framework to be private - i.e. - not discoverable to other processes than my java vm -- then for some reason JNA doesn't do it.

I know MacOS dynamic loader, when trying to locate a library/framework for any normal (native) MacOS process, does NOT start searching the above locations, but first within several standard "private" locations: (also known as rpath search-path)

  • in the "Frameworks" directory at the same location as the binary from which the process was loaded: e.g. path/to/my/binary/Frameworks/mySDK.framework
  • in the "Frameworks" directory at the place where dynamic loader loaded the process (in Application bundles, that would be the myApp.app/Contents/Frameworks/mySDK.framework folder.

So, you can usually create a 'Frameworks' directory of your own right next to your binary, and place your framework in it.

However - JNA misses that. I tried to create a "Frameworks" directory within the "Zulu" - in zulu-11.jre/Contents/Home/bin right next to the 'java' binary, and in other places - but JNA won't find in any of them.

I wonder why, and if there is any documentation for that.

The trick of installing a symlink to my custom framework in /Library/Frameworks may serve you, but I cannot allow other processes to find or load my framework.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top