Watir will not install with XP x86 or Win 7 x64. Getting error building native extension for the FFI gem - ruby

I am currently trying to install watir on my PC but currently hitting the errors below and I cannot think why this is happening?
I am following the steps below to install:
Download ruby 1.9.2:
http://www.ruby-lang.org/en/downloads/
Install.
Download RubyGems:
http://rubygems.org/pages/download
Install.
Download the DevKit so that native extensions can be built:
ruby dk.rb init
ruby dk.rb review
ruby dk.rb install
gem update --system (or to do more quickly: gem update --system --no-rdoc --no-ri)
gem install watir
When I do this all I get is the error log below. Does anyone know how I can get Watir to install please?
C:\Documents and Settings\IE User\Desktop\Ruby and Eclipse>gem install watir
Fetching: win32-api-1.4.8-x86-mingw32.gem (100%)
Fetching: windows-api-0.4.0.gem (100%)
Fetching: windows-pr-1.2.1.gem (100%)
Fetching: win32-process-0.6.5.gem (100%)
Fetching: xml-simple-1.1.1.gem (100%)
Fetching: hoe-2.12.4.gem (100%)
Fetching: s4t-utils-1.0.4.gem (100%)
WARNING: s4t-utils-1.0.4 has an invalid nil value for #cert_chain
Fetching: builder-3.0.0.gem (100%)
Fetching: user-choices-1.1.6.1.gem (100%)
Fetching: commonwatir-2.0.4.gem (100%)
Fetching: nokogiri-1.5.0-x86-mingw32.gem (100%)
Fetching: ffi-1.0.11.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing watir:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include... no
checking for rb_thread_blocking_region()... yes
checking for ruby_thread_has_gvl_p()... yes
checking for ruby_native_thread_p()... yes
checking for rb_thread_call_with_gvl()... yes
creating extconf.h
creating Makefile
make
C:/Ruby192/bin/ruby -e "puts 'EXPORTS', 'Init_ffi_c'" > ffi_c-i386-mingw32.def
Configuring libffi
make -C "/c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/ffi_c/libffi"
make[1]: Entering directory /c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/
ffi_c/libffi'
make "AR_FLAGS=" "CC_FOR_BUILD=" "CFLAGS=" "CXXFLAGS=" "CFLAGS_FOR_BUILD=" "CFLA
GS_FOR_TARGET=" "INSTALL=/usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c
-m 644" "INSTALL_PROGRAM=/usr/bin/install -c" "INSTALL_SCRIPT=/usr/bin/install -
c" "JC1FLAGS=" "LDFLAGS=" "LIBCFLAGS=" "LIBCFLAGS_FOR_TARGET=" "MAKE=make" "MAKE
INFO=/bin/sh /c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/ffi_c/libffi/mis
sing --run makeinfo " "PICFLAG=" "PICFLAG_FOR_TARGET=" "RUNTESTFLAGS=" "SHELL=/b
in/sh" "exec_prefix=/usr/local" "infodir=/usr/local/share/info" "libdir=/usr/loc
al/lib" "prefix=/usr/local" "AR=ar" "AS=as" "CC=gcc" "CXX=g++" "LD=c:/documents
and settings/ie user/desktop/ruby and eclipse/mingw/mingw32/bin/ld.exe" "NM=/usr
/mingw/bin/nm" "RANLIB=ranlib" "DESTDIR=" all-recursive
make[2]: Entering directory/c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/
ffi_c/libffi'
Making all in include
make[3]: Entering directory /c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/
ffi_c/libffi/include'
make[3]: Nothing to be done forall'.
make[3]: Leaving directory /c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/f
fi_c/libffi/include'
Making all in testsuite
make[3]: Entering directory/c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/
ffi_c/libffi/testsuite'
make[3]: Nothing to be done for all'.
make[3]: Leaving directory/c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/f
fi_c/libffi/testsuite'
Making all in man
make[3]: Entering directory /c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/
ffi_c/libffi/man'
make[3]: Nothing to be done forall'.
make[3]: Leaving directory /c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/f
fi_c/libffi/man'
make[3]: Entering directory/c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/
ffi_c/libffi'
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./inc
lude -Iinclude -I./src -Wall -g -fexceptions -c -o src/debug.lo src/debug.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wa
ll -g -fexceptions -c src/debug.c -DDLL_EXPORT -DPIC -o src/.libs/debug.o
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./inc
lude -Iinclude -I./src -Wall -g -fexceptions -c -o src/prep_cif.lo src/prep_ci
f.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wa
ll -g -fexceptions -c src/prep_cif.c -DDLL_EXPORT -DPIC -o src/.libs/prep_cif.o
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./inc
lude -Iinclude -I./src -Wall -g -fexceptions -c -o src/types.lo src/types.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wa
ll -g -fexceptions -c src/types.c -DDLL_EXPORT -DPIC -o src/.libs/types.o
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./inc
lude -Iinclude -I./src -Wall -g -fexceptions -c -o src/raw_api.lo src/raw_api.
c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wa
ll -g -fexceptions -c src/raw_api.c -DDLL_EXPORT -DPIC -o src/.libs/raw_api.o
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./inc
lude -Iinclude -I./src -Wall -g -fexceptions -c -o src/java_raw_api.lo src/jav
a_raw_api.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wa
ll -g -fexceptions -c src/java_raw_api.c -DDLL_EXPORT -DPIC -o src/.libs/java_r
aw_api.o
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./inc
lude -Iinclude -I./src -Wall -g -fexceptions -c -o src/closures.lo src/closure
s.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wa
ll -g -fexceptions -c src/closures.c -DDLL_EXPORT -DPIC -o src/.libs/closures.o
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./inc
lude -Iinclude -I./src -Wall -g -fexceptions -c -o src/x86/ffi.lo src/x86/ffi.
c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wa
ll -g -fexceptions -c src/x86/ffi.c -DDLL_EXPORT -DPIC -o src/x86/.libs/ffi.o
/bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iin
clude -I./src -I. -I./include -Iinclude -I./src -c -o src/x86/win32.lo src/x86
/win32.S
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -I.
-I./include -Iinclude -I./src -c src/x86/win32.S -DDLL_EXPORT -DPIC -o src/x86
/.libs/win32.o
/bin/sh ./libtool --tag=CC --mode=link gcc -Wall -g -fexceptions -version-inf
o grep -v '^#' ./libtool-version -no-undefined -o libffi.la -rpath /usr/local
/lib src/debug.lo src/prep_cif.lo src/types.lo src/raw_api.lo src/java_raw_api.l
o src/closures.lo src/x86/ffi.lo src/x86/win32.lo
libtool: link: gcc -o .libs/libffi.dll.a src/.libs/debug.o src/.libs/prep_cif.o
src/.libs/types.o src/.libs/raw_api.o src/.libs/java_raw_api.o src/.libs/closur
es.o src/x86/.libs/ffi.o src/x86/.libs/win32.o echo "X" | /usr/bin/sed -e 1
s/^X// -e 's/ -lc$//' -link -dll
c:/documents and settings/ie user/desktop/ruby and eclipse/mingw/bin/../lib/gcc/
mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -link
collect2: ld returned 1 exit status
make[3]: *** [libffi.la] Error 1
make[3]: Leaving directory /c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/f
fi_c/libffi'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory/c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/f
fi_c/libffi'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/f
fi_c/libffi'
make: *** ["/c/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/ffi_c/libffi"/.li
bs/libffi_convenience.a] Error 2
Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.1
1 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/ext/ffi_c/gem_m
ake.out
I am totally at a loss as to how to rectify this. I have tried this on both XP x86 and Win 7 X64 to no avail.
Thanks in advance
Andy

the later versions of FFI have been a source of problems for some, both because they no longer include a native windows version and have to build one on the fly, but also due to some incompatabilities with watir or webdrivers
Try doing this
gem uninstall ffi
(just in case there is anything that managhed to get installed)
gem install ffi -v 1.0.9
Then install watir or watir-webdriver
Update:
The latest versions of FFI work fine with Watir and Watir-Webdriver, however do not come 'precompiled' as earlier versions did. So to install them on a PC If you do not already have it, you will need to get Devkit. Once you have devkit installed and have run the setup scripts for it, you can use gem install ffi to get the latest FFI gem installed and it should work just fine.

I have updated my instructions on how to install Watir on Windows. If you follow them you will be able to install the latest versions of Ruby, Watir and ffi.
https://github.com/zeljkofilipin/watirbook/blob/master/installation/windows.md

Related

Has anyone built gcc 8.2.0 on OpenBSD 6.3?

I am getting the following error when I try to build gcc 8.2.0 on OpenBSD 6.3:
/bin/sh ./libtool --tag=CC --mode=compile /home/shane/gcc-8.2.0/host-i386-unknown-openbsd6.3/gcc/xgcc -B/home/shane/gcc-8.2.0/host-i386-unknown-openbsd6.3/gcc/ -B/opt/gcc-8.2.0/i386-unknown-openbsd6.3/bin/ -B/opt/gcc-8.2.0/i386-unknown-openbsd6.3/lib/ -isystem /opt/gcc-8.2.0/i386-unknown-openbsd6.3/include -isystem /opt/gcc-8.2.0/i386-unknown-openbsd6.3/sys-include -DHAVE_CONFIG_H -I../.././libatomic/config/x86 -I../.././libatomic/config/posix -I../.././libatomic -I. -march=i486 -mtune=i386 -fomit-frame-pointer -Wall -Werror -pthread -g -O2 -MT fence.lo -MD -MP -MF .deps/fence.Tpo -c -o fence.lo ../.././libatomic/fence.c
libtool: compile: /home/shane/gcc-8.2.0/host-i386-unknown-openbsd6.3/gcc/xgcc -B/home/shane/gcc-8.2.0/host-i386-unknown-openbsd6.3/gcc/ -B/opt/gcc-8.2.0/i386-unknown-openbsd6.3/bin/ -B/opt/gcc-8.2.0/i386-unknown-openbsd6.3/lib/ -isystem /opt/gcc-8.2.0/i386-unknown-openbsd6.3/include -isystem /opt/gcc-8.2.0/i386-unknown-openbsd6.3/sys-include -DHAVE_CONFIG_H -I../.././libatomic/config/x86 -I../.././libatomic/config/posix -I../.././libatomic -I. -march=i486 -mtune=i386 -fomit-frame-pointer -Wall -Werror -pthread -g -O2 -MT fence.lo -MD -MP -MF .deps/fence.Tpo -c ../.././libatomic/fence.c -fPIC -DPIC -o .libs/fence.o
../.././libatomic/fence.c:26:10: fatal error: stdatomic.h: No such file or directory
#include <stdatomic.h>
^~~~~~~~~~~~~
compilation terminated.
gmake[4]: *** [Makefile:491: fence.lo] Error 1
gmake[4]: Leaving directory '/home/shane/gcc-8.2.0/i386-unknown-openbsd6.3/libatomic'
gmake[3]: *** [Makefile:524: all-recursive] Error 1
gmake[3]: Leaving directory '/home/shane/gcc-8.2.0/i386-unknown openbsd6.3/libatomic'
gmake[2]: *** [Makefile:360: all] Error 2
gmake[2]: Leaving directory '/home/shane/gcc-8.2.0/i386-unknown-openbsd6.3/libatomic'
gmake[1]: *** [Makefile:21680: all-target-libatomic] Error 2
gmake[1]: Leaving directory '/home/shane/gcc-8.2.0'
gmake: *** [Makefile:943: all] Error 2
My process:
Install OpenBSD (using defaults)
Run syspatch
Add some packages:
# pkg_add wget
# pkg_add gmp mpfr libmpc
# pkg_add gmake
Get the source:
$ wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-8.2.0/gcc-8.2.0.tar.gz
$ tar xzf gcc-8.2.0.tar.gz
$ cd gcc-8.2.0
Build:
$ ./configure --prefix=/opt/gcc-8.2.0 --with-gmp=/usr/local --enable-languages=c,c++
$ gmake
This also fails with gcc 8.1.0 in a similar way.
I also tried using clang rather than gcc to build, like this:
$ CC=cc CXX=c++ ./configure --prefix=/opt/gcc-8.2.0 --with-gmp=/usr/local --enable-languages=c,c++
That made no difference, which makes some sense as apparently it is failing in stage 3 (gcc compiling itself again for a final check).
Annoyingly, there is a stdatomic.h file in the tarball:
$ find gcc-8.2.0 -name stdatomic.h
gcc-8.2.0/gcc/ginclude/stdatomic.h
So I have no idea what I am missing.
Has anyone successfully built this? How?

gcc 4.9.2 build error on RHEL6

I'm trying to build gcc 4.9.2 on RHEL6, as follows:
unpack the source tarball (to ~/gcc-4.9.2)
in the source dir:
./contrib/download_prerequisites
create a separate build directory ~/gcc-4.9.2-build
in the build dir:
~/gcc-4.9.2/configure --prefix=/usr/local/gcc-4.9.2
make
This fails with:
make[6]: Entering directory `/root/gcc-4.9.2-build-try0/x86_64-unknown-linux-gnu/libjava/classpath/native/jni/java-math'
/bin/sh ../../../libtool --tag=CC --mode=compile /root/gcc-4.9.2-build-try0/./gcc/xgcc -B/root/gcc-4.9.2-build-try0/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include -DHAVE_CONFIG_H -I. -I/root/gcc-4.9.2/libjava/classpath/native/jni/java-math -I../../../include -I/root/gcc-4.9.2/libjava/classpath/include -I/root/gcc-4.9.2/libjava/classpath/native/jni/classpath -I/root/gcc-4.9.2/libjava/classpath/native/jni/native-lib -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long -I/usr/include -g -O2 -MT gnu_java_math_GMP.lo -MD -MP -MF .deps/gnu_java_math_GMP.Tpo -c -o gnu_java_math_GMP.lo /root/gcc-4.9.2/libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c
libtool: compile: /root/gcc-4.9.2-build-try0/./gcc/xgcc -B/root/gcc-4.9.2-build-try0/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include -DHAVE_CONFIG_H -I. -I/root/gcc-4.9.2/libjava/classpath/native/jni/java-math -I../../../include -I/root/gcc-4.9.2/libjava/classpath/include -I/root/gcc-4.9.2/libjava/classpath/native/jni/classpath -I/root/gcc-4.9.2/libjava/classpath/native/jni/native-lib -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long -I/usr/include -g -O2 -MT gnu_java_math_GMP.lo -MD -MP -MF .deps/gnu_java_math_GMP.Tpo -c /root/gcc-4.9.2/libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c -fPIC -DPIC -o .libs/gnu_java_math_GMP.o
mv -f .deps/gnu_java_math_GMP.Tpo .deps/gnu_java_math_GMP.Plo
/bin/sh ../../../libtool --tag=CC --mode=link /root/gcc-4.9.2-build-try0/./gcc/xgcc -B/root/gcc-4.9.2-build-try0/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long -I/usr/include -g -O2 -module -version-info 0:0:0 -no-undefined -lgmp -avoid-version -o libjavamath.la -rpath /usr/local/gcc-4.9.2/lib/../lib64/gcj-4.9.2-15 gnu_java_math_GMP.lo ../../../native/jni/classpath/jcl.lo -lrt
libtool: link: /root/gcc-4.9.2-build-try0/./gcc/xgcc -B/root/gcc-4.9.2-build-try0/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include -shared .libs/gnu_java_math_GMP.o ../../../native/jni/classpath/.libs/jcl.o /root/gcc-4.9.2-build-try0/./gmp/.libs/libgmp.a -lrt -Wl,-soname -Wl,libjavamath.so -o .libs/libjavamath.so
/usr/bin/ld: /root/gcc-4.9.2-build-try0/./gmp/.libs/libgmp.a(mp_set_fns.o): relocation R_X86_64_32 against `__gmp_default_allocate' can not be used when making a shared object; recompile with -fPIC
/root/gcc-4.9.2-build-try0/./gmp/.libs/libgmp.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[6]: *** [libjavamath.la] Error 1
make[6]: Leaving directory `/root/gcc-4.9.2-build-try0/x86_64-unknown-linux-gnu/libjava/classpath/native/jni/java-math'
A little googling pointed me at the --disable-shared option, which sort of helped, but now:
in the build dir:
~/gcc-4.9.2/configure --prefix=/usr/local/gcc-4.9.2 --disable-shared
make
yielded a slightly different error:
make[8]: Entering directory `/root/gcc-4.9.2-build/x86_64-unknown-linux-gnu/32/libjava/classpath/native/jni/classpath'
/bin/sh ../../../libtool --tag=CC --mode=compile /root/gcc-4.9.2-build/./gcc/xgcc -B/root/gcc-4.9.2-build/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include -m32 -DHAVE_CONFIG_H -I. -I/root/gcc-4.9.2/libjava/classpath/native/jni/classpath -I../../../include -I/root/gcc-4.9.2/libjava/classpath/include -I/root/gcc-4.9.2/libjava/classpath/native/jni/classpath -I/root/gcc-4.9.2/libjava/classpath/native/jni/native-lib -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long -Wstrict-prototypes -pedantic -fexceptions -fasynchronous-unwind-tables -g -O2 -m32 -MT jcl.lo -MD -MP -MF .deps/jcl.Tpo -c -o jcl.lo /root/gcc-4.9.2/libjava/classpath/native/jni/classpath/jcl.c
libtool: compile: not configured to build any kind of library
libtool: compile: See the libtool documentation for more information.
libtool: compile: Fatal configuration error.
make[8]: *** [jcl.lo] Error 1
make[8]: Leaving directory `/root/gcc-4.9.2-build/x86_64-unknown-linux-gnu/32/libjava/classpath/native/jni/classpath'
Adding the --enable-static option made no difference.
Any suggestions on what might be wrong?
BTW, gcc 4.9.1 gave the same errors.
System: Linux 2.6.32-431.29.2.el6.x86_64 #1 SMP Sun Jul 27 15:55:46 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
System is RHEL6, fully updated via Redhat, and has no custom RPMs that I know of.
Just completed building 4.9.2 on a CentOS 6.4 VM using 4.4.7 gcc. Ran into an out of space issue, which caused the build to fail, but once resolved, everything else went smoothly.
Looks like your build is failing in the Java side of town? Not sure if you need the Java support, so have you tried compiling just the c/c++ language support?
~/gcc-4.9.2/configure --enable-languages=c,c++ ...
I also don't require 32-bit binaries, so I add --disable-multilib to the list of configure parameters.

Error installing mysql2 gem on Ubuntu Server 11.10: /usr/bin/ld: cannot find -lmysqlclient_r

I got the same error on Ubuntu Server 11.10 x64 mentioned in some other posts:
Post #1
Post #2
The mysql2 gem cannot be compiled due "cannot find -lmysqlclient_r "
I'm using:
Ruby v1.8.7
MySQL v5.5.25-1
Rails 3.2.3
Gem 1.8.24
I installed the package libmysqlclient-dev and it still doesn't work.
The files
- libmysqlclient_r.a
- libmysqlclient_r.so
- libmysqlclient_r.so.18
- libmysqlclient_r.so.18.0.0
are located at /usr/lib/x86_64-linux-gnu/
So I created symlinks in /usr/lib/
Ii still doesn't work :(
Any idea??
$ sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c mysql2_ext.c
./client.h:16:1: warning: ârb_thread_blocking_regionâ defined but not used [-Wunused-function]
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c result.c
result.c: In function ârb_mysql_result_fetch_rowâ:
result.c:258:31: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
result.c:272:58: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
result.c:315:33: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c client.c
client.c: In function ârb_mysql_client_infoâ:
client.c:539:3: warning: variable âwrapperâ set but not used [-Wunused-but-set-variable]
gcc -shared -o mysql2.so mysql2_ext.o result.o client.o -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lruby1.8 -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -lpthread -lrt -ldl -lcrypt -lm -lc
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1

Install rb-inotify on solaris

I am trying to install rb-inotify on a Solaris box. Result of uname -a:
SunOS test9 5.10 Generic_142901-02 i86pc i386 i86pc
ruby-1.8.7 and rubygems-1.7.2 have been compiled and installed but after running
gem install rb-inotify
I got following error message:
Building native extensions. This could take a while...
ERROR: Error installing rb-inotify:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include... no
checking for rb_thread_blocking_region()... no
checking for ruby_thread_has_gvl_p()... no
checking for ruby_native_thread_p()... no
checking for rb_thread_call_with_gvl()... no
creating extconf.h
creating Makefile
make
Configuring libffi
make -C "/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi"
make[1]: Entering directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi'
make "AR_FLAGS=" "CC_FOR_BUILD=" "CFLAGS=" "CXXFLAGS=" "CFLAGS_FOR_BUILD=" "CFLAGS_FOR_TARGET=" "INSTALL=./install-sh -c" "INSTALL_DATA=./install-sh -c -m 644" "INSTALL_PROGRAM=./install-sh -c" "INSTALL_SCRIPT=./install-sh -c" "JC1FLAGS=" "LDFLAGS=" "LIBCFLAGS=" "LIBCFLAGS_FOR_TARGET=" "MAKE=make" "MAKEINFO=/bin/bash /usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi/missing --run makeinfo " "PICFLAG=" "PICFLAG_FOR_TARGET=" "RUNTESTFLAGS=" "SHELL=/bin/bash" "exec_prefix=/usr/local" "infodir=/usr/local/share/info" "libdir=/usr/local/lib" "prefix=/usr/local" "AR=false" "AS=as" "CC=gcc" "CXX=g++" "LD=/usr/ccs/bin/ld" "NM=/usr/ccs/bin/nm -p" "RANLIB=:" "DESTDIR=" all-recursive
make[2]: Entering directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi'
Making all in include
make[3]: Entering directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi/include'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi/include'
Making all in testsuite
make[3]: Entering directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite'
Making all in man
make[3]: Entering directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi/man'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi/man'
make[3]: Entering directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi'
restore=: && backupdir=".am$$" && \
am__cwd=`pwd` && CDPATH="${ZSH_VERSION+.}:" && cd . && \
rm -rf $backupdir && mkdir $backupdir && \
if (/bin/bash /usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi/missing --run makeinfo --version) >/dev/null 2>&1; then \
for f in doc/libffi.info doc/libffi.info-[0-9] doc/libffi.info-[0-9][0-9] doc/libffi.i[0-9] doc/libffi.i[0-9][0-9]; do \
if test -f $f; then mv $f $backupdir; restore=mv; else :; fi; \
done; \
else :; fi && \
cd "$am__cwd"; \
if /bin/bash /usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi/missing --run makeinfo -I doc -I ./doc \
-o doc/libffi.info ./doc/libffi.texi; \
then \
rc=0; \
CDPATH="${ZSH_VERSION+.}:" && cd .; \
else \
rc=$?; \
CDPATH="${ZSH_VERSION+.}:" && cd . && \
$restore $backupdir/* `echo "./doc/libffi.info" | sed 's|[^/]*$||'`; \
fi; \
rm -rf $backupdir; exit $rc
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c -o src/debug.lo src/debug.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/debug.c -fPIC -DPIC -o src/.libs/debug.o
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c -o src/prep_cif.lo src/prep_cif.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/prep_cif.c -fPIC -DPIC -o src/.libs/prep_cif.o
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c -o src/types.lo src/types.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/types.c -fPIC -DPIC -o src/.libs/types.o
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c -o src/raw_api.lo src/raw_api.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/raw_api.c -fPIC -DPIC -o src/.libs/raw_api.o
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c -o src/java_raw_api.lo src/java_raw_api.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/java_raw_api.c -fPIC -DPIC -o src/.libs/java_raw_api.o
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c -o src/closures.lo src/closures.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/closures.c -fPIC -DPIC -o src/.libs/closures.o
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c -o src/x86/ffi64.lo src/x86/ffi64.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/x86/ffi64.c -fPIC -DPIC -o src/x86/.libs/ffi64.o
/bin/bash ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -I. -I./include -Iinclude -I./src -c -o src/x86/unix64.lo src/x86/unix64.S
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -I. -I./include -Iinclude -I./src -c src/x86/unix64.S -fPIC -DPIC -o src/x86/.libs/unix64.o
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c -o src/x86/ffi.lo src/x86/ffi.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/x86/ffi.c -fPIC -DPIC -o src/x86/.libs/ffi.o
/bin/bash ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -I. -I./include -Iinclude -I./src -c -o src/x86/sysv.lo src/x86/sysv.S
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -I. -I./include -Iinclude -I./src -c src/x86/sysv.S -fPIC -DPIC -o src/x86/.libs/sysv.o
/bin/bash ./libtool --tag=CC --mode=link gcc -Wall -g -fexceptions -version-info `grep -v '^#' ./libtool-version` -o libffi.la -rpath /usr/local/lib src/debug.lo src/prep_cif.lo src/types.lo src/raw_api.lo src/java_raw_api.lo src/closures.lo src/x86/ffi64.lo src/x86/unix64.lo src/x86/ffi.lo src/x86/sysv.lo
libtool: link: gcc -shared -Wl,-z -Wl,text -Wl,-h -Wl,libffi.so.5 -o .libs/libffi.so.5.0.10 src/.libs/debug.o src/.libs/prep_cif.o src/.libs/types.o src/.libs/raw_api.o src/.libs/java_raw_api.o src/.libs/closures.o src/x86/.libs/ffi64.o src/x86/.libs/unix64.o src/x86/.libs/ffi.o src/x86/.libs/sysv.o -lc
libtool: link: (cd ".libs" && rm -f "libffi.so.5" && ln -s "libffi.so.5.0.10" "libffi.so.5")
libtool: link: (cd ".libs" && rm -f "libffi.so" && ln -s "libffi.so.5.0.10" "libffi.so")
libtool: link: ( cd ".libs" && rm -f "libffi.la" && ln -s "../libffi.la" "libffi.la" )
/bin/bash ./libtool --tag=CC --mode=link gcc -Wall -g -fexceptions -o libffi_convenience.la src/debug.lo src/prep_cif.lo src/types.lo src/raw_api.lo src/java_raw_api.lo src/closures.lo src/x86/ffi64.lo src/x86/unix64.lo src/x86/ffi.lo src/x86/sysv.lo
libtool: link: false cru .libs/libffi_convenience.a src/.libs/debug.o src/.libs/prep_cif.o src/.libs/types.o src/.libs/raw_api.o src/.libs/java_raw_api.o src/.libs/closures.o src/x86/.libs/ffi64.o src/x86/.libs/unix64.o src/x86/.libs/ffi.o src/x86/.libs/sysv.o
make[3]: *** [libffi_convenience.la] Error 1
make[3]: Leaving directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi'
make: *** ["/usr/local/lib/ruby/gems/1.8/gems/ffi-1.0.11/ext/ffi_c/libffi"/.libs/libffi_convenience.a] Error 2
Then I found out on rb-notify's homepage saying it's a wrapper for Linux kernel subsystem inotify. Is that the reason why I can't install it on a Solaris box?
However, I do know people are installing rb-notify on Windows machines without any problem, so how could that work if inotify is a "Linux kernel subsystem"?
inotify is not implemented in Solaris.
As alternatives to inotify:
see port_create/port_associate: http://blogs.oracle.com/darren/entry/file_notification_in_opensolaris_and
dtrace: http://constantin.glez.de/blog/2010/04/how-automatically-update-your-home-media-server-library-dtrace

Library fails to build if "autoreconf -i" is run before ./configure

I'm working with a tool that is supposed to simplify the build process of Unix-based apps. One of the things it does automatically is run "autoreconf -i" before doing "./configure". However, when it tries to build the expat library on OSX (Lion), the build fails:
$ tar xfz expat-2.0.1.tar.gz; cd expat-2.0.1
$ autoreconf -i
glibtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `conftools'.
glibtoolize: copying file `conftools/ltmain.sh'
glibtoolize: You should add the contents of the following files to `aclocal.m4':
glibtoolize: `/usr/bin/../share/aclocal/libtool.m4'
glibtoolize: `/usr/bin/../share/aclocal/ltoptions.m4'
glibtoolize: `/usr/bin/../share/aclocal/ltversion.m4'
glibtoolize: `/usr/bin/../share/aclocal/ltsugar.m4'
glibtoolize: `/usr/bin/../share/aclocal/lt~obsolete.m4'
glibtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.in and
glibtoolize: rerunning glibtoolize, to keep the correct libtool macros in-tree.
glibtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
$ ./configure
(Lots of output here)
configure: creating ./config.status
config.status: creating Makefile
config.status: WARNING: Makefile.in seems to ignore the --datarootdir setting
config.status: creating expat_config.h
$ make
bin/sh ./libtool --silent --mode=compile gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -o lib/xmlparse.lo -c lib/xmlparse.c
./libtool: line 473: CDPATH: command not found
./libtool: line 1297: func_opt_split: command not found
libtool: Version mismatch error. This is libtool 2.2.10, but the
libtool: definition of this LT_INIT comes from an older release.
libtool: You should recreate aclocal.m4 with macros from libtool 2.2.10
libtool: and run autoconf again.
On the other hand, if I don't do autoreconf first, it build just fiine:
$ cd ..; rm -r expat-2.0.1; tar xfz expat-2.0.1.tar.gz; cd expat-2.0.1
$ ./configure
(Lots of output here)
configure: creating ./config.status
config.status: creating Makefile
config.status: creating expat_config.h
$ make
/bin/sh ./libtool --silent --mode=compile gcc -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -o lib/xmlparse.lo -c lib/xmlparse.c
/bin/sh ./libtool --silent --mode=compile gcc -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -o lib/xmltok.lo -c lib/xmltok.c
/bin/sh ./libtool --silent --mode=compile gcc -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -o lib/xmlrole.lo -c lib/xmlrole.c
/bin/sh ./libtool --silent --mode=link gcc -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -no-undefined -version-info 6:2:5 -rpath /usr/local/lib -o libexpat.la lib/xmlparse.lo lib/xmltok.lo lib/xmlrole.lo
gcc -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -o xmlwf/xmlwf.o -c xmlwf/xmlwf.c
gcc -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -o xmlwf/xmlfile.o -c xmlwf/xmlfile.c
gcc -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -o xmlwf/codepage.o -c xmlwf/codepage.c
gcc -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -o xmlwf/unixfilemap.o -c xmlwf/unixfilemap.c
/bin/sh ./libtool --silent --mode=link gcc -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions -DHAVE_EXPAT_CONFIG_H -o xmlwf/xmlwf xmlwf/xmlwf.o xmlwf/xmlfile.o xmlwf/codepage.o xmlwf/unixfilemap.o libexpat.la
What is "autoreconf -i" doing, and why is it causing the build to fail?
I think the problem is here:
libtool: Version mismatch error. This is libtool 2.2.10, but the
libtool: definition of this LT_INIT comes from an older release.
libtool: You should recreate aclocal.m4 with macros from libtool 2.2.10
libtool: and run autoconf again.
In my experience with OS X Leopard and Snow Leopard (I have not tried Lion yet), the autotools actually installed with OS X are not recent enough to actually reconfigure anything for the system. So I usually grab the latest autotools from a GNU mirror and make a local version of them if I need to reconfigure.
"autoreconf -i" copies files from the installed GNU autotools to AC_CONFIG_AUX_DIR, an in this case is probably ltmain.sh.
A user should never run autoreconf. As ldav1s points out (+1), the autotools installed on your box do not match the tools used to generate the tarball. There are many packages in the wild that recommend (or even require) the user to run autoconf in some form to build the package; those packages are broken. A properly built package should build on a machine that does not have any of the autotools installed, and unless you are a package maintainer you should probably just uninstall them. IMO, they should not be included in default installations.
If you use a package that requires the autotools to build, please report that as a bug to the package maintainer. If a version control system (eg git, hg, svn ) is being used as the distribution mechanism, then you will either need to run the autotools to build the package or the package will have to include autotools generated files in the repository. This is why version control systems should not be used as a distribution tool for packages that use the autotools.

Resources