2013-07-23 2 views
0

Je travaille sur la construction d'un wrapper JRuby autour du projet vlcj. Pour l'instant j'utilise JBundler pour gérer les dépendances.Création d'imports avec vlcj et JRuby sous OSX

Jbundler me donne un .jbundler/classpath.rb comme:

JBUNDLER_CLASSPATH = [] 
JBUNDLER_CLASSPATH << '/Users/myth/.m2/repository/uk/co/caprica/vlcj/2.4.1/vlcj-2.4.1.jar' 
JBUNDLER_CLASSPATH << '/Users/myth/.m2/repository/net/java/dev/jna/jna/3.5.2/jna-3.5.2.jar' 
JBUNDLER_CLASSPATH << '/Users/myth/.m2/repository/net/java/dev/jna/platform/3.5.2/platform-3.5.2.jar' 
JBUNDLER_CLASSPATH.freeze 
JBUNDLER_CLASSPATH.each { |c| require c } 

est le code ici qui tente d'importer vlcj:

require 'java' 
require '.jbundler/classpath' 

java_import 'com.sun.jna.NativeLibrary' 
java_import 'uk.co.caprica.vlcj.runtime.RuntimeUtil' 
java_import 'uk.co.caprica.vlcj.binding.LibVlc' 

class Player 

end 

J'utilise rspec pour conduire mon code, Cependant à chaque exécution je finis toujours avec:

/Users/myth/.rvm/rubies/jruby-1.7.4/bin/jruby -S rspec spec/bollywood_spec/player_spec.rb 
NameError: cannot link Java class uk.co.caprica.vlcj.binding.LibVlc, probable missing dependency: Unable to load library 'vlc': JNA native support (darwin/libvlc.dylib) not found in resource path() 
      for_name at org/jruby/javasupport/JavaClass.java:1242 
    get_proxy_class at org/jruby/javasupport/JavaUtilities.java:34 
     java_import at file:/Users/myth/.rvm/rubies/jruby-1.7.4/lib/jruby.jar!/jruby/java/core_ext/object.rb:26 
       map at org/jruby/RubyArray.java:2417 
     java_import at file:/Users/myth/.rvm/rubies/jruby-1.7.4/lib/jruby.jar!/jruby/java/core_ext/object.rb:22 
      (root) at /Users/myth/Learn/Code/Projects/bollywood/lib/bollywood/player.rb:6 
      require at org/jruby/RubyKernel.java:1054 
      (root) at /Users/myth/Learn/Code/Projects/bollywood/lib/bollywood.rb:1 
      require at org/jruby/RubyKernel.java:1054 
      (root) at /Users/myth/Learn/Code/Projects/bollywood/lib/bollywood.rb:2 
      require at org/jruby/RubyKernel.java:1054 
      (root) at /Users/myth/Learn/Code/Projects/bollywood/spec/spec_helper.rb:1 
      (root) at /Users/myth/Learn/Code/Projects/bollywood/spec/spec_helper.rb:2 
       load at org/jruby/RubyKernel.java:1073 
      (root) at file:/Users/myth/.rvm/rubies/jruby-1.7.4/lib/jruby.jar!/jruby/kernel19/kernel.rb:1 
       each at org/jruby/RubyArray.java:1617 
    require_relative at file:/Users/myth/.rvm/rubies/jruby-1.7.4/lib/jruby.jar!/jruby/kernel19/kernel.rb:21 
      (root) at /Users/myth/Learn/Code/Projects/bollywood/spec/bollywood_spec/player_spec.rb:1 
      (root) at /Users/myth/.rvm/gems/jruby-1.7.4/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:1 
    load_spec_files at /Users/myth/.rvm/gems/jruby-1.7.4/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819 
rake aborted! 
/Users/myth/.rvm/rubies/jruby-1.7.4/bin/jruby -S rspec spec/bollywood_spec/player_spec.rb failed 
/Users/myth/.rvm/gems/jruby-1.7.4/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:156:in `run_task' 
/Users/myth/.rvm/gems/jruby-1.7.4/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:124:in `initialize' 
org/jruby/RubyBasicObject.java:1709:in `__send__' 
org/jruby/RubyKernel.java:2213:in `send' 
/Users/myth/.rvm/gems/jruby-1.7.4/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:122:in `initialize' 
org/jruby/RubyProc.java:255:in `call' 
org/jruby/RubyArray.java:1617:in `each' 
org/jruby/RubyArray.java:1617:in `each' 
org/jruby/RubyKernel.java:1073:in `load' 
org/jruby/RubyKernel.java:1093:in `eval' 
/Users/myth/.rvm/gems/jruby-1.7.4/bin/ruby_noexec_wrapper:14:in `(root)' 

Comment résoudre le problème?

Répondre

1

Je trouve la solution au problème:

Sur MacOSX je dois NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(),"/Applications/VLC .app/Contents/MacOS/lib"); être avant la déclaration d'importation java_import 'uk.co.caprica.vlcj.binding.LibVlc' pour la JNA pour trouver les bibliothèques natives.