SOLVED - see below.
I am trying to install the rfuse gem on an ubuntu 12.04 vagrant image. In it's extconf, it checks for fuse and fails.
I have apt-get
installed fuse
and fuse-utils
, and /lib/libfuse.so.2
exists. I tried the session below, which:
nm
to verify that a main function does exist in the library (I don't know if this is valid.)LD_LIBRARY_PATH
(not sure if this is valid either)I'm stuck now because I'm not sure how this is failing. Is it not finding the library? If it is, is it not finding the right function? Where is it looking for libraries? What other techniques do I have to debug this?
vagrant@n1:~$ ruby2.1 -rmkmf -e 'have_library("fuse")'
checking for main() in -lfuse... no
vagrant@n1:~$ nm -D -C -g /lib/libfuse.so.2 | grep main
0000000000016080 T cuse_lowlevel_main
0000000000016570 T fuse_main
0000000000016840 T fuse_main
0000000000016860 T fuse_main_compat1
0000000000016840 T fuse_main_compat2
0000000000016880 T fuse_main_real
0000000000016890 T fuse_main_real
0000000000016830 T fuse_main_real
0000000000016880 T fuse_main_real_compat22
0000000000016830 T fuse_main_real_compat25
vagrant@n1:~$ env LD_LIBRARY_PATH=/lib ruby2.1 -rmkmf -e 'have_library("fuse")'
checking for main() in -lfuse... no
vagrant@n1:~$ uname -a
Linux n1 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
vagrant@n1:~$ file /lib/libfuse.so.2.8.6
/lib/libfuse.so.2.8.6: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0xdb7e3872302adb18b73703be89224938e5575441, stripped
vagrant@n1:~$ file $(which ruby2.1)
/usr/bin/ruby2.1: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x9a5173cfb87a0bdb27026d7913fcff5729652848, stripped
Here is a Vagrantfile that sets up the machine I am testing with:
$script = <<SCRIPT
sudo apt-get update
sudo apt-get install python-software-properties -y
sudo apt-add-repository ppa:brightbox/ruby-ng -y
sudo apt-get update
sudo apt-get install ruby2.1 ruby2.1-dev fuse fuse-utils -y
SCRIPT
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.provision "shell", inline: $script
config.vm.define "n1" do |n1|
n1.vm.hostname = "n1"
n1.vm.network "private_network", ip: "172.20.20.10"
end
end
SOLUTION
Calling have_library
(or any mkmf
code) leaves mkmf.log
in the working directory. Looking at that, I saw the following failure:
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.1.0 -I/usr/include/ruby-2.1.0/ruby/backward -I/usr/include/ruby-2.1.0 -I. -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby2.1-2.1.2/debian/lib -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.1 -lfuse -lpthread -lrt -lgmp -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -lfuse
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
/* end */
I tried ld -lfuse --verbose
and was able to get more details on the failure, including where it was looking for the library:
attempt to open /lib/libfuse.so failed
attempt to open /lib/libfuse.a failed
Neither of those exist! I don't know why not, but I tried symlinking it sudo ln -s /lib/libfuse.so.2 /lib/libfuse.so
and now ld
worked.
Continuing with the gem install, I was also missing two libraries: sudo apt-get install -y libfuse-dev make
. With those additions, I am able to install and use the gem.
Your mkmf call should generate an mkmf.log in the current directory. In it should be the particulars of how it calls gcc, and what exactly didn't work. You can extract those commands and continue to drill down.