SWIG: Ruby Overload Problems

I have a sinatra web application and a C ++ library that I can “require” in a sinatra (ruby) using the bindings created by swig,

I also have a second, very similar library, in which the function names are partially the same as in the first. When I demand both of them, the one that is loaded first wins, i.e. Calls to ambiguous function names are always mapped to this library.

The reason is that "require" loads only those things that are not loaded yet, while "load" reloads no matter what. However, the “download” does not seem to apply to .so files, only to ruby ​​source files. Any help?

thanks

0
ruby swig require load sinatra
source share
1 answer

require looks into the $ "array to determine if the module should be reloaded . You can try removing it and requesting it. I'm not sure this will work for your use case, although it seems that the namespace may still be dirty.

 irb(main):001:0> require 'mysql' => true irb(main):002:0> require 'mysql' => false irb(main):003:0> $".delete('mysql.so') => "mysql.so" irb(main):004:0> require 'mysql' /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/mysql.so: warning: already initialized constant MysqlRes /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/mysql.so: warning: already initialized constant MysqlField /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/mysql.so: warning: already initialized constant MysqlError /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/mysql.so: warning: already initialized constant VERSION /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/mysql.so: warning: already initialized constant OPT_CONNECT_TIMEOUT /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/mysql.so: warning: already initialized constant OPT_COMPRESS /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/mysql.so: warning: already initialized constant OPT_NAMED_PIPE <snip> => true 
0
source share

All Articles