I installed some native libraries in /usr/local/lib.
I am now trying to install a gem which needs these in order to build correctly but, the gem build fails as it cannot find the 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 tried setting a bunch of environment variables but nothing seems to work:
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
What is the best way to solve this problem?
I've read the comments and I know you made it work, but I think I have the proper solution to the problem.
have_library
checks whether it is possible to use the given library in your environment. It does so by including the library header and using one of its functions in a temporary C source file. If it is successful, then the library must be available.
have_library 'geocodesearch'
checking for main() in -lgecodesearch... no
have_library
could not use the main
function from geocodesearch
. This either means the library is not available or the function doesn't exist. In your case, it is probably the latter.
You can tell have_library
which function to try by passing a second argument. For example:
have_library 'geocodesearch', 'geocodesearch_version'
checking for geocodesearch_version() in -lgecodesearch...
If you don't specify, it will simply look for the main
function. You can also specify the headers to be included:
have_library 'geocodesearch', 'geocodesearch_version', %w(geocode/search.h)
In the comments, you said you solved your problem by simply eliminating the have_library
calls. This is a localized solution; you will have to reapply it to any new versions of the gem.
I recommend sending a pull request to the author containing the necessary adjustments. The bug will be permanently fixed and you will also help others who might be having the same issue.
mkmf
reference:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With