0

I was able to compile the native 0.6.0 libraries of JCuda on a Mac OSX 10.9.3 64-bit system (http://www.jcuda.org/downloads/downloads.html). Unfortunately Im not smart enough to package everything into a jar. Can someone help me to do so? I created a Netbeans project and copied the contents of all provided Java src folders into it. Then I packaged everything into a jar. Using Jarsplice 0.4.0 I then tried to build a Jar file containing all the native library files listed below (except the first .a file). Unfortunately when I linked the resulting jar into my project and run it, it wasnt working since a libJCudaRuntime-apple-x86_64.jnilib was missing.

Thank you in advance Radek

My lib folder contains: libCommonJNI.a libJCublas-apple-x86_64.dylib libJCublas2-apple-x86_64.dylib libJCudaDriver-apple-x86_64.dylib libJCudaRuntime-apple-x86_64.dylib libJCufft-apple-x86_64.dylib libJCurand-apple-x86_64.dylib libJCusparse-apple-x86_64.dylib

RayDeeA
  • 271
  • 3
  • 12
  • To load a library you will need to extract it from the jar to somewhere the OS actually can load from (the file system). A method I've seen commonly used is to use getResource for the library in the jar, then copying it to system temp and load from there (using qualified path). Some even have libraries for multiple OS's in the same jar and select which one fits the OS. – Durandal Jun 06 '14 at 16:16
  • I already have the native lib. I compiled from the sources provided at http://www.jcuda.org/downloads/downloads.html "Source code of all libraries". You can see the file structure at http://pastebin.com/EKE7mRsu. Notice that there are also .*Java Folders containing src folders with java files inside. What I basically want is to package a jar containing all the compiled Java sources AND the native libs in one. So I can put it to my local repository. – RayDeeA Jun 06 '14 at 17:24
  • @RayDeeA, thanks to Marco13 for mention my project, i've just add Mac OS X libs, check this out :)https://github.com/MysterionRise/mavenized-jcuda – Mysterion Jun 15 '14 at 18:53

1 Answers1

2

Just to have this answered here as well: The native libraries can not be packed directly into a JAR (or rather: They can currently not be loaded if they are only contained in the JAR).

Although the infrastructure of the JCuda LibUtils class basically offers the possibility to do this, it is not "officially" supported. One reason for that is that this would only make sense when all native libraries for all operating systems were available (in 32 and 64 bit). Then it would be possible to put all these libraries into a JAR, and unpack and load them transparently at runtime.

It usually takes a while until all native libraries are available. The problem may be alleviated with things like https://github.com/MysterionRise/mavenized-jcuda , which manages the dependencies to the native libraries.

Marco13
  • 53,703
  • 9
  • 80
  • 159