Manuel Meurer Manuel Meurer - 21 days ago 12
Ruby Question

Trying to install Ruby gems on Synology DiskStation DS216j, cannot find Ruby header files

I am trying to run some Ruby scripts on my Synology DiskStation DS216j. I successfully managed to install Ruby 2.3.1 via OPKG/Entware-ng but when I try to install gems with native extensions, I get an error:

$ sudo gem install io-console

Building native extensions. This could take a while...
ERROR: Error installing io-console:
ERROR: Failed to build gem native extension.

current directory: /volume1/@entware-ng/opt/lib/ruby/gems/2.3/gems/io-console-0.4.6
/opt/bin/ruby -r ./siteconf20161113-31591-ucvjgl.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/bin/$(RUBY_BASE_NAME)
/opt/lib/ruby/2.3/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/lib/ruby/2.3/mkmf.rb:571:in `block in try_compile'
from /opt/lib/ruby/2.3/mkmf.rb:524:in `with_werror'
from /opt/lib/ruby/2.3/mkmf.rb:571:in `try_compile'
from /opt/lib/ruby/2.3/mkmf.rb:835:in `macro_defined?'
from extconf.rb:7:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/opt/lib/ruby/gems/2.3/extensions/arm-linux/2.3/io-console-0.4.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/lib/ruby/gems/2.3/gems/io-console-0.4.6 for inspection.
Results logged to /opt/lib/ruby/gems/2.3/extensions/arm-linux/2.3/io-console-0.4.6/gem_make.out


The content of
/opt/lib/ruby/gems/2.3/extensions/arm-linux/2.3/io-console-0.4.6/mkmf.log
:

"arm-openwrt-linux-gnueabi-gcc -o conftest -I/opt/include/ruby-2.3/arm-linux-gnu -I/opt/include/ruby-2.3/ruby/backward -I/opt/include/ruby-2.3 -I. -I/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/include -I/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/include -I/media/ware3/Entware-ng.2016.08/staging_dir/toolchain-arm_cortex-a9_gcc-5.4.0_glibc-2.23_eabi/usr/include -I/media/ware3/Entware-ng.2016.08/staging_dir/toolchain-arm_cortex-a9_gcc-5.4.0_glibc-2.23_eabi/include -I/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib/libiconv-full/include -I/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib/libintl-full/include -D_FILE_OFFSET_BITS=64 -O2 -pipe -march=armv7-a -mtune=cortex-a9 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=soft -I/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib/libiconv-full/include -I/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib/libintl-full/include -fPIC conftest.c -L. -L/opt/lib -L. -L/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib -L/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/lib -Wl,-rpath,/opt/lib -Wl,-rpath-link=/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3 -L/media/ware3/Entware-ng.2016.08/staging_dir/toolchain-arm_cortex-a9_gcc-5.4.0_glibc-2.23_eabi/usr/lib -L/media/ware3/Entware-ng.2016.08/staging_dir/toolchain-arm_cortex-a9_gcc-5.4.0_glibc-2.23_eabi/lib -L/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib/libiconv-full/lib -Wl,-rpath-link=/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib/libiconv-full/lib -L/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib/libintl-full/lib -Wl,-rpath-link=/media/ware3/Entware-ng.2016.08/staging_dir/target-arm_cortex-a9_glibc-2.23_eabi/opt/lib/libintl-full/lib -L/media/ware3/Entware-ng.2016.08/build_dir/target-arm_cortex-a9_glibc-2.23_eabi/ruby-2.3.1 -fstack-protector -rdynamic -Wl,-export-dynamic -lruby -lpthread -lgmp -ldl -lcrypt -lm -lc"
/opt/bin/ld: cannot find -lruby
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */


/opt/bin/ld: cannot find -lruby
seems to be the real error here.

Googling this results in recommendations to install the Ruby source code/headers which I did:

$ wget -qO- http://pkg.entware.net/binaries/armv7/include/include.tar.gz | tar xvz -C /opt/include

[snip]

$ ls -lah /opt/include/ruby-2.3/

drwxr-xr-x 4 1000 1000 4.0K Aug 19 12:42 .
drwxr-xr-x 179 root root 20.0K Oct 10 09:32 ..
drwxr-xr-x 3 1000 1000 4.0K Aug 19 12:42 arm-linux-gnu
drwxr-xr-x 3 1000 1000 4.0K Aug 19 12:42 ruby
-rw-r--r-- 1 1000 1000 868 Jul 11 2012 ruby.h


So I guess the real question is: how can I tell
/opt/bin/ld
that the Ruby header files are located in
/opt/include/ruby-2.3/
?


Any help or tips are appreciated, thanks!

UPDATE: I tried
sudo gem install io-console -- --with-opt-include=/opt/include/ruby-2.3
, same result:

Building native extensions with: '--with-opt-include=/opt/include/ruby-2.3'
This could take a while...
ERROR: Error installing io-console:
ERROR: Failed to build gem native extension.

current directory: /volume1/@entware-ng/opt/lib/ruby/gems/2.3/gems/io-console-0.4.6
/opt/bin/ruby -r ./siteconf20161113-2005-jbxmcd.rb extconf.rb --with-opt-include=/opt/include/ruby-2.3
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/bin/$(RUBY_BASE_NAME)
/opt/lib/ruby/2.3/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/lib/ruby/2.3/mkmf.rb:571:in `block in try_compile'
from /opt/lib/ruby/2.3/mkmf.rb:524:in `with_werror'
from /opt/lib/ruby/2.3/mkmf.rb:571:in `try_compile'
from /opt/lib/ruby/2.3/mkmf.rb:835:in `macro_defined?'
from extconf.rb:7:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/opt/lib/ruby/gems/2.3/extensions/arm-linux/2.3/io-console-0.4.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/lib/ruby/gems/2.3/gems/io-console-0.4.6 for inspection.
Results logged to /opt/lib/ruby/gems/2.3/extensions/arm-linux/2.3/io-console-0.4.6/gem_make.out


Why does the
--with-opt-include=/opt/include/ruby-2.3
not show up in
Provided configuration options
?

Max Max
Answer

/opt/bin/ld: cannot find -lruby means that the linker can't find the Ruby library, not the headers. You need the compiled shared object library at /opt/lib/libruby.so or static library /opt/lib/libruby-static.a.

Comments