Skip to content

Instantly share code, notes, and snippets.

@wmoxam
Created September 24, 2012 15:52
Show Gist options
  • Save wmoxam/3776660 to your computer and use it in GitHub Desktop.
Save wmoxam/3776660 to your computer and use it in GitHub Desktop.
FFI Y U NO WURK????
$ ls -l /opt/local/lib/libmdb*
-rwxr-xr-x 1 root admin 69640 19 Sep 09:54 /opt/local/lib/libmdb.0.dylib
-rw-r--r-- 1 root admin 103040 19 Sep 09:54 /opt/local/lib/libmdb.a
lrwxr-xr-x 1 root admin 14 19 Sep 09:54 /opt/local/lib/libmdb.dylib -> libmdb.0.dylib
-rwxr-xr-x 1 root admin 1078 19 Sep 09:54 /opt/local/lib/libmdb.la
-rwxr-xr-x 1 root admin 41604 19 Sep 09:54 /opt/local/lib/libmdbsql.0.dylib
-rw-r--r-- 1 root admin 45120 19 Sep 09:54 /opt/local/lib/libmdbsql.a
lrwxr-xr-x 1 root admin 17 19 Sep 09:54 /opt/local/lib/libmdbsql.dylib -> libmdbsql.0.dylib
-rwxr-xr-x 1 root admin 1092 19 Sep 09:54 /opt/local/lib/libmdbsql.la
ruby-1.8.7-p352 :001 > require 'rubygems'
=> true
ruby-1.8.7-p352 :002 > require 'nice-ffi'
=> true
ruby-1.8.7-p352 :003 >
ruby-1.8.7-p352 :004 > module Mdb
ruby-1.8.7-p352 :005?> extend NiceFFI::Library
ruby-1.8.7-p352 :006?> load_library 'mdb'
ruby-1.8.7-p352 :007?> end
=> "/opt/local/lib/libmdb.dylib"
ruby-1.8.7-p352 :008 >
ruby-1.8.7-p352 :009 > module MdbSql
ruby-1.8.7-p352 :010?> extend NiceFFI::Library
ruby-1.8.7-p352 :011?> load_library 'mdbsql'
ruby-1.8.7-p352 :012?> end
LoadError: Could not load mdbsql.
from /Users/wesleymoxam/.rvm/gems/ruby-1.8.7-p352/gems/nice-ffi-0.4/lib/nice-ffi/library.rb:98:in `load_library'
from (irb):11
@universal
Copy link

works for me ;-)

require 'rubygems'
require 'bundler/setup'
require 'nice-ffi'
module Mdb
  extend NiceFFI::Library
  load_library 'mdb'
end

module MdbSql
  extend NiceFFI::Library
  load_library 'mdbsql'
end

puts MdbSql.methods.sort

@wmoxam
Copy link
Author

wmoxam commented Sep 24, 2012

Looks like macports version of mdbtools is shit

LoadError: Could not open library 'libmdbsql.dylib': dlopen(libmdbsql.dylib, 5): Symbol not found: _mdb_find_indexable_sargs
Referenced from: /opt/local/lib/libmdbsql.dylib
Expected in: flat namespace
in /opt/local/lib/libmdbsql.dylib.
Could not open library 'mdbsql': dlopen(mdbsql, 5): image not found
from /Users/wesleymoxam/.rvm/gems/ruby-1.8.7-p352/gems/ffi-1.1.5/lib/ffi/library.rb:121:in ffi_lib' from /Users/wesleymoxam/.rvm/gems/ruby-1.8.7-p352/gems/ffi-1.1.5/lib/ffi/library.rb:88:inmap'
from /Users/wesleymoxam/.rvm/gems/ruby-1.8.7-p352/gems/ffi-1.1.5/lib/ffi/library.rb:88:in `ffi_lib'
from (irb):11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment