mkmf does not allow for linking against custom libraries when a system library is present
Hopefully the title is not confusing, but the short story is that mkmf outputs a makefile that first searches the default lib path before searching any user provided lib paths. This is not an issue until one tries to link against an included library whose version is different than a preexisting system library.
The issue cropped up while trying to install the rugged gem (libgit2 wrapper) and a full dialog on the issue can be found on github https://github.com/libgit2/rugged/issues/351.
I was able to fix the issue with the attached patch (https://github.com/muff1nman/ruby/commit/a0c8bc32cfc11e61c5b9703bff243934c6509210)
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r45640.
mkmf.rb: prefer $LIBPATH than $DEFLIBPATH
- lib/mkmf.rb (
create_makefile): prefer user specified
$DEFLIBPATH. [ruby-core:62100] [ruby-trunk - Bug #9760]
Updated by knu (Akinori MUSHA) over 7 years ago
The monkey patch I mentioned above was backed out due to a serious problem found, that is, if an instance of libruby.so (of the same soname as the running ruby) is found in a user-given path that is different from the one for the running ruby used for build, it will be picked by the linker and the resulted extension will cause a SEGV in run time.
So, it turned out DEFLIBPATH took precedence over LIBPATH for a good reason and I'm afraid it should not have been simply changed this way.
Updated by onur (Onur Küçük) over 5 years ago
We have a system where
- Ruby 1.8.7-p374 is installed system wide from distribution packages
- There is a user setup with RVM to run Ruby 2.x running Redmine with Mysql
During Redmine bundle install, mysql2 gem is linking against the system Ruby, leading to issues like missing symbols etc. for the generated SO. The issue is happening with 2.2.3, 2.2.4 and 2.3.0 but it seems it is fixed in 2.3.1. I did not bisect but r52267 is probably what fixed it, thank you !