2

我正在尝试在我的 Synology DiskStation DS216j 上运行一些 Ruby 脚本。我成功地通过OPKG/Entware-ng安装了 Ruby 2.3.1,但是当我尝试安装带有本机扩展的 gems 时,我得到一个错误:

$ 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

的内容/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似乎是这里真正的错误。

谷歌搜索这会导致建议安装我所做的 Ruby 源代码/头文件:

$ 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

所以我想真正的问题是:我怎么知道/opt/bin/ldRuby 头文件位于/opt/include/ruby-2.3/

任何帮助或提示表示赞赏,谢谢!

4

1 回答 1

1

/opt/bin/ld: cannot find -lruby意味着链接器找不到 Ruby,而不是标头。您需要编译后的共享库/opt/lib/libruby.so或静态库/opt/lib/libruby-static.a

于 2016-11-13T16:20:59.810 回答