FreeBSD 7.0 に zipruby をインストールできない
# gem install zipruby Building native extensions. This could take a while... ERROR: Error installing zipruby: ERROR: Failed to build gem native extension. /usr/local/bin/ruby18 extconf.rb install zipruby checking for zlib.h... yes checking for main() in -lz... yes checking for fseeko()... yes checking for ftello()... yes checking for mkstemp()... yes creating Makefile make cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c mkstemp.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c tmpfile.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c zipruby.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c zipruby_archive.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c zipruby_error.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c zipruby_file.c zipruby_file.c:4:20: error: alloca.h: No such file or directory *** Error code 1 Stop in /usr/local/lib/ruby/gems/1.8/gems/zipruby-0.2.9/ext. Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/zipruby-0.2.9 for inspection. Results logged to /usr/local/lib/ruby/gems/1.8/gems/zipruby-0.2.9/ext/gem_make.out
zipruby の gem_make.out を確認する
# less /usr/local/lib/ruby/gems/1.8/gems/zipruby-0.2.9/ext/gem_make.out /usr/local/bin/ruby18 extconf.rb install zipruby checking for zlib.h... yes checking for main() in -lz... yes checking for fseeko()... yes checking for ftello()... yes checking for mkstemp()... yes creating Makefile make cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c mkstemp.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c tmpfile.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c zipruby.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c zipruby_archive.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c zipruby_error.c cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_ZLIB_H -DHAVE_FSEEKO -DHAVE_FTELLO -DHAVE_MKSTEMP -fPIC -O2 -fno-strict-aliasing -pipe -fPIC -c zipruby_file.c zipruby_file.c:4:20: error: alloca.h: No such file or directory *** Error code 1 Stop in /usr/local/lib/ruby/gems/1.8/gems/zipruby-0.2.9/ext.
alloca.h は FreeBSD には存在しない
確かに alloca.h は存在しないようだ。
t# ls -l /usr/include/ | less total 1488 -r--r--r-- 1 root wheel 5870 Feb 25 2008 FlexLexer.h -r--r--r-- 1 root wheel 6305 Feb 25 2008 _ctype.h lrwxrwxrwx 1 root wheel 16 Aug 31 17:26 _semaphore.h -> sys/_semaphore.h -r--r--r-- 1 root wheel 2176 Feb 25 2008 a.out.h lrwxrwxrwx 1 root wheel 9 Aug 31 17:26 aio.h -> sys/aio.h -r--r--r-- 1 root wheel 10189 Feb 25 2008 alias.h drwxr-xr-x 2 root wheel 512 Aug 31 17:26 altq -r--r--r-- 1 root wheel 3006 Feb 25 2008 ar.h -r--r--r-- 1 root wheel 23618 Feb 25 2008 archive.h -r--r--r-- 1 root wheel 12465 Feb 25 2008 archive_entry.h drwxr-xr-x 2 root wheel 512 Aug 31 17:26 arpa -r--r--r-- 1 root wheel 813 Feb 25 2008 asn1_err.h -r--r--r-- 1 root wheel 2739 Feb 25 2008 assert.h (後略)
alloca.h は Linux 用?
alloca.h は libc6-dev をインストールすると、ヘッダファイルとして保存されるようだ。
- Manpage of ALLOCA
- パッケージ: libc6-dev
標準的な C ライブラリを用いるプログラムのコンパイルやリンクに必要とされるシンボリックリンク、ヘッダおよびオブジェクトファイルが含まれます。
解決方法は?
解決方法を探していたところ、nagios の ML で同様の質問がなされていた。
その質問に対する回答は下記の通り。
Fri, 03 Nov 2006 01:37:44 -0800
I had this as well (FreeBSD 6.1-RELEASE.)
alloca.h is a common file for Linux installations, but is not required
as such on FreeBSD.After hunting around on the net, I found the solution is to create a
file at "/usr/include/alloca.h" with the single line: "#include"
eg.echo "#include
" > /usr/include/alloca.h Then re-compile Nagios plugins. You may need to set
CCFLAGS="-I/usr/include" but I think this is a standard search path anyway.Andy.
Jason Kerr wrote:
> Problem: regex_internal.h includes alloca.h which does not exist in FreeBSD.
>
> Version: nagios-plugins-1.4.5
> OS: FreeBSD 5.5-STABLE
>
> Snipped output from config.log:
> configure:35748: checking for working alloca.h
> configure:35769: gcc -o conftest -g -O2 -L. conftest.c >&5
> conftest.c:127:20: alloca.h: No such file or directory
> configure:35775: $? = 1
> configure: failed program was:
> | /* confdefs.h. */
> |
>
>
> Snipped output from make:
> In file included from regex.c:55:
> regex_internal.h:458:20: alloca.h: No such file or directory
> *** Error code 1
>
> Stop in /usr/home/xxx/nagios-plugins-1.4.5/lib.
> *** Error code 1
>
> Stop in /usr/home/xxx/nagios-plugins-1.4.5/lib.
> *** Error code 1
>
> Stop in /usr/home/xxx/nagios-plugins-1.4.5/lib.
> *** Error code 1
>
> Stop in /usr/home/xxx/nagios-plugins-1.4.5.
> *** Error code 1
>
> Stop in /usr/home/xxx/nagios-plugins-1.4.5.
>
>
> In FreeBSD the alloca function is contained in stdlib.h, but the
> manpage discourages its use. "BUGS The alloca() function is machine
> and compiler dependent; its use is dis-couraged."
>
>
> In regex_internal.h do we need something like:
> #ifdef HAVE_ALLOCA_H> #else
> /* do nothing??? */
> #endif
>
> Thanks,
> Jason要するに、
alloca.h is a common file for Linux installations, but is not required
as such on FreeBSD.alloca.h does not exist in FreeBSD.だから
I found the solution is to create a
file at "/usr/include/alloca.h" with the single line: "#include"
eg.echo "#include
" > /usr/include/alloca.h ということらしい。
実際に試してみる
# echo "#include <stdlib.h>" > /usr/include/alloca.h # ls -l /usr/include/alloca.h -rw-r--r-- 1 root wheel 20 Oct 30 07:03 /usr/include/alloca.h # cat /usr/include/alloca.h #include <stdlib.h>もう一度、zipruby をインストールしてみる。
# gem install zipruby Building native extensions. This could take a while... Successfully installed zipruby-0.2.9 1 gem installed Installing ri documentation for zipruby-0.2.9... Installing RDoc documentation for zipruby-0.2.9... /root# irb irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'zipruby' => true irb(main):003:0>インストールは成功したようだ。
実際に正常に動作するかどうかは、まだ確認をしていない。