S
Steven Jenkins
I have a vendor-supplied library and some SWIG-generated wrapper code
for it. The vendor supplies both a static (.a) and dynamic (.so)
library. Platform is Gentoo Linux (kernel 2.6.10).
I have (mostly) successfully built an extension using the standard mkmf
technique. I can load the library and run simple Ruby scripts using it.
On more complex scripts, however, Ruby crashes with a segfault.
On closer examination, it turns out that the vendor library is doing
things you shouldn't do in a shared library. (They don't normally
provide the shared library; they did it for me because I wanted to build
an extension.) I can cause the same crash using a C example. It works
fine with the static library.
So, I'm trying to build Ruby with a static extension. I followed the
steps in the Pickaxe: edited ext/Setup, moved my extension code into
ext/jpl/cradle, and did 'make clean all install'. Everything appears to
work, but when I try to start Ruby, it fails with
/tmp/ruby-1.8.2/bin/ruby: error while loading shared libraries:
libcradleapi.so.0: cannot open shared object file: No such file or directory
libcradleapi.so.0 is the vendor library, not the wrapper code. I renamed
all libcradleapi.so* and re-ran ldconfig before compiling Ruby, so I
have no idea why it's trying to load the dynamic library.
Here's my extconf.rb:
require 'mkmf'
dir_config('cradleapi')
if have_library('cradleapi')
create_makefile('cradle')
else
File.open('Makefile', 'w') do |f|
f.puts('all:')
end
end
The conditional is there because this extension is an optional part of a
bigger package. Is there some magic I need to add to make it link
against libcradleapi.a?
Any help appreciated.
Steve
for it. The vendor supplies both a static (.a) and dynamic (.so)
library. Platform is Gentoo Linux (kernel 2.6.10).
I have (mostly) successfully built an extension using the standard mkmf
technique. I can load the library and run simple Ruby scripts using it.
On more complex scripts, however, Ruby crashes with a segfault.
On closer examination, it turns out that the vendor library is doing
things you shouldn't do in a shared library. (They don't normally
provide the shared library; they did it for me because I wanted to build
an extension.) I can cause the same crash using a C example. It works
fine with the static library.
So, I'm trying to build Ruby with a static extension. I followed the
steps in the Pickaxe: edited ext/Setup, moved my extension code into
ext/jpl/cradle, and did 'make clean all install'. Everything appears to
work, but when I try to start Ruby, it fails with
/tmp/ruby-1.8.2/bin/ruby: error while loading shared libraries:
libcradleapi.so.0: cannot open shared object file: No such file or directory
libcradleapi.so.0 is the vendor library, not the wrapper code. I renamed
all libcradleapi.so* and re-ran ldconfig before compiling Ruby, so I
have no idea why it's trying to load the dynamic library.
Here's my extconf.rb:
require 'mkmf'
dir_config('cradleapi')
if have_library('cradleapi')
create_makefile('cradle')
else
File.open('Makefile', 'w') do |f|
f.puts('all:')
end
end
The conditional is there because this extension is an optional part of a
bigger package. Is there some magic I need to add to make it link
against libcradleapi.a?
Any help appreciated.
Steve