Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get ruby to find a native lib?

40 views
Skip to first unread message

Adam Russell

unread,
Feb 13, 2012, 11:35:44 AM2/13/12
to
I have installed some native libraries. They are in /usr/local/lib.
I am now trying to install a ruby gem which needs these in order to
build correctly but the gem build fails as it cannot find these
libraries.
The gem's extconf.rb file tries to confirm it can find the library with
have_library() but this fails for some reason.
I have tried setting a bunch of environment variables (see below for my
tests in irb) but nothing seems to work.
What is the best way to solve this problem?


irb(main):003:0> require 'mkmf'
=> true
irb(main):004:0> have_library('gecodesearch')
checking for main() in -lgecodesearch... no
=> false
irb(main):005:0> ENV['LD_LIBRARY_PATH']='/usr/local/lib'
=> "/usr/local/lib"
irb(main):006:0> have_library('gecodesearch')
checking for main() in -lgecodesearch... no
=> false
irb(main):007:0> ENV['DYLD_LIBRARY_PATH']='/usr/local/lib'
=> "/usr/local/lib"
irb(main):008:0> have_library('gecodesearch')
checking for main() in -lgecodesearch... no
=> false
irb(main):009:0> have_library('libgecodesearch')
checking for main() in -llibgecodesearch... no
=> false
irb(main):010:0> ENV['C_INCLUDE_PATH']='/usr/local/lib'
=> "/usr/local/lib"
irb(main):011:0> have_library('gecodesearch')
checking for main() in -lgecodesearch... no
=> false
irb(main):012:0> ENV['PATH']='/usr/local/lib'
=> "/usr/local/lib"
irb(main):013:0> have_library('gecodesearch')
checking for main() in -lgecodesearch... no
=> false

Robert Klemme

unread,
Feb 13, 2012, 2:39:56 PM2/13/12
to
On 02/13/2012 05:35 PM, Adam Russell wrote:
> I have installed some native libraries. They are in /usr/local/lib.
> I am now trying to install a ruby gem which needs these in order to
> build correctly but the gem build fails as it cannot find these
> libraries.
> The gem's extconf.rb file tries to confirm it can find the library with
> have_library() but this fails for some reason.
> I have tried setting a bunch of environment variables (see below for my
> tests in irb) but nothing seems to work.
> What is the best way to solve this problem?

Hmm, did you try

$ LD_LIBRARY_PATH=/usr/local/lib gem install XYZ

? Maybe also export CPPFLAGS=-I/usr/local/include

Kind regards

robert

Adam Russell

unread,
Feb 13, 2012, 5:57:33 PM2/13/12
to
Yes. Unfortunately, I have tried both of those things and neither one helps.

xman

unread,
Feb 16, 2012, 12:54:12 PM2/16/12
to
Try:

export LIBRARY_PATH=/usr/local/lib

That works for me in Linux + GCC
The LD_LIBRARY_PATH is only effective when executing, not at compile time.
0 new messages