From: Yangkook Kim Date: 2008-08-30T19:35:12+09:00 Subject: [ruby-list:45443] Ruby/Pcapをコンパイルできない ------=_Part_13301_12794232.1220092810805 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Content-Disposition: inline kimと申します。 先ほどruby-list-ctlに間違ってこのメールを出してしまいました。 大変失礼しました。 もう一度こちらに送らせていただきます。 掲題にあるライブラリを使いたいのですが、extconf.rbを実行すると以下のエラーを吐きます。 ------------------------------------------------------------------------------------------ checking for socket() in -lsocket... no checking for gethostbyname() in -lxnet... no checking for hstrerror()... no checking for pcap.h... yes checking for pcap_open_live() in -lpcap... no *** 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. ------------------------------------------------------------------------------------------ 私の分かる範囲で考えると上記のエラーで分かることは、関数socket(),gethostbyname(),hstrerror(), pcap_open_live()を見つけることができないと言っている。そこでextconf.rbの中身を見てみると、 ------------------------------------------------------------------------------------------ require 'mkmf' 1.pcap_dir = with_config("pcap-dir", "/usr") 2.pcap_includedir = with_config("pcap-includedir", "/usr/include") 3.pcap_libdir = with_config("pcap-libdir", "/usr/lib/") 4.$CFLAGS = "-I#{pcap_includedir}" 5.$LDFLAGS = "-L#{pcap_libdir}" 6.have_library("socket", "socket") 7.have_library("xnet", "gethostbyname") 8.have_func("hstrerror") 9.if have_header("pcap.h") && have_library("pcap", "pcap_open_live") 10. have_func("pcap_compile_nopcap") 11. create_makefile("pcap") 12.end ------------------------------------------------------------------------------------------ socket()とgethostbyname()に関しては、それぞれhave_libraryでsocetとxnetライブラリに 探しに行っているのだと思いますが、socketとxnetライブラリというのがシステム内を探しても 見つかりません(socket.soとかlibxnetをlocateで調べてみた)。インストールすればいいのだろうけど、 socketとxnetというのがなんというライブラリなのかよく分からないため、インストールすることが できません(Unixだとlibsocket.soとかXnetとかあるようなのですが、Linuxでは見つけることができない。) この二つのライブラリに関してどうしたらいいのかわからない、といのが私の一つ目の質問です。 二つ目の質問は、extconf.rb内の3行目でlibpcapがある場所を指定しているにも関わらず、extconf.rb を実行すると"checking for pcap_open_live() in -lpcap... no"という具合にこの関数が 見つからないと怒られる.しかし、下記でわかるようにlibpcapはちゃんとあるように思える。 ---------------------------------------------------------------------- [hiro@hiro01 lib]$ ls -la | grep pcap -rwxr-xr-x 1 root root 172160 2007-08-22 19:04 libpcap.0.9.7 lrwxrwxrwx 1 root root 11 2008-08-30 14:05 libpcap.so -> libpcap.0.9 lrwxrwxrwx 1 root root 13 2008-08-30 14:09 libpcap.so.0.9 -> libpcap.0.9.7 ------------------------------------------------------------------------- ですのでlibpcapがあるのに上記エラーが出てしまう、というのが私の二つ目の質問です。 システムはLinux 2.6.25.14-69.fc8 i686 athlon i386で Rubyはruby 1.8.6になります。 なお下記がmkmf.logの内容になります。 どうかよろしくお願いします。 ------------------------------------------------------------------------- have_library: checking for socket() in -lsocket... -------------------- no "gcc -o conftest -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -I/usr/include conftest.c -L. -L/usr/lib -L/usr/lib/ -lruby-static -lsocket -lpthread -ldl -lcrypt -lm -lc" conftest.c: In function 't': conftest.c:3: error: 'socket' undeclared (first use in this function) conftest.c:3: error: (Each undeclared identifier is reported only once conftest.c:3: error: for each function it appears in.) checked program was: /* begin */ 1: /*top*/ 2: int main() { return 0; } 3: int t() { void ((*volatile p)()); p = (void ((*)()))socket; return 0; } /* end */ "gcc -o conftest -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -I/usr/include conftest.c -L. -L/usr/lib -L/usr/lib/ -lruby-static -lsocket -lpthread -ldl -lcrypt -lm -lc" /usr/bin/ld: line 1: /bin: is a directory /usr/bin/ld: line 2: COPYING: command not found /usr/bin/ld: line 3: COPYING: command not found /usr/bin/ld: line 4: syntax error near unexpected token `(' /usr/bin/ld: line 4: ` * Copyright (c) 1996,2007 Oracle. All rights reserved.' collect2: ld はステータス 2 で終了しました checked program was: /* begin */ 1: /*top*/ 2: int main() { return 0; } 3: int t() { socket(); return 0; } /* end */ -------------------- have_library: checking for gethostbyname() in -lxnet... -------------------- no "gcc -o conftest -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -I/usr/include conftest.c -L. -L/usr/lib -L/usr/lib/ -lruby-static -lxnet -lpthread -ldl -lcrypt -lm -lc" conftest.c: In function 't': conftest.c:3: error: 'gethostbyname' undeclared (first use in this function) conftest.c:3: error: (Each undeclared identifier is reported only once conftest.c:3: error: for each function it appears in.) checked program was: /* begin */ 1: /*top*/ 2: int main() { return 0; } 3: int t() { void ((*volatile p)()); p = (void ((*)()))gethostbyname; return 0; } /* end */ "gcc -o conftest -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -I/usr/include conftest.c -L. -L/usr/lib -L/usr/lib/ -lruby-static -lxnet -lpthread -ldl -lcrypt -lm -lc" /usr/bin/ld: line 1: /bin: is a directory /usr/bin/ld: line 2: COPYING: command not found /usr/bin/ld: line 3: COPYING: command not found /usr/bin/ld: line 4: syntax error near unexpected token `(' /usr/bin/ld: line 4: ` * Copyright (c) 1996,2007 Oracle. All rights reserved.' collect2: ld はステータス 2 で終了しました checked program was: /* begin */ 1: /*top*/ 2: int main() { return 0; } 3: int t() { gethostbyname(); return 0; } /* end */ -------------------- have_func: checking for hstrerror()... -------------------- no "gcc -o conftest -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -I/usr/include conftest.c -L. -L/usr/lib -L/usr/lib/ -lruby-static -lpthread -ldl -lcrypt -lm -lc" conftest.c: In function 't': conftest.c:3: error: 'hstrerror' undeclared (first use in this function) conftest.c:3: error: (Each undeclared identifier is reported only once conftest.c:3: error: for each function it appears in.) checked program was: /* begin */ 1: /*top*/ 2: int main() { return 0; } 3: int t() { void ((*volatile p)()); p = (void ((*)()))hstrerror; return 0; } /* end */ "gcc -o conftest -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -I/usr/include conftest.c -L. -L/usr/lib -L/usr/lib/ -lruby-static -lpthread -ldl -lcrypt -lm -lc" /usr/bin/ld: line 1: /bin: is a directory /usr/bin/ld: line 2: COPYING: command not found /usr/bin/ld: line 3: COPYING: command not found /usr/bin/ld: line 4: syntax error near unexpected token `(' /usr/bin/ld: line 4: ` * Copyright (c) 1996,2007 Oracle. All rights reserved.' collect2: ld はステータス 2 で終了しました checked program was: /* begin */ 1: /*top*/ 2: int main() { return 0; } 3: int t() { hstrerror(); return 0; } /* end */ -------------------- have_header: checking for pcap.h... -------------------- yes "gcc -E -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -I/usr/include conftest.c -o conftest.i" checked program was: /* begin */ 1: #include /* end */ -------------------- have_library: checking for pcap_open_live() in -lpcap... -------------------- no "gcc -o conftest -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -I/usr/include conftest.c -L. -L/usr/lib -L/usr/lib/ -lruby-static -lpcap -lpthread -ldl -lcrypt -lm -lc" conftest.c: In function 't': conftest.c:3: error: 'pcap_open_live' undeclared (first use in this function) conftest.c:3: error: (Each undeclared identifier is reported only once conftest.c:3: error: for each function it appears in.) checked program was: /* begin */ 1: /*top*/ 2: int main() { return 0; } 3: int t() { void ((*volatile p)()); p = (void ((*)()))pcap_open_live; return 0; } /* end */ "gcc -o conftest -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -I/usr/include conftest.c -L. -L/usr/lib -L/usr/lib/ -lruby-static -lpcap -lpthread -ldl -lcrypt -lm -lc" /usr/bin/ld: line 1: /bin: is a directory /usr/bin/ld: line 2: COPYING: command not found /usr/bin/ld: line 3: COPYING: command not found /usr/bin/ld: line 4: syntax error near unexpected token `(' /usr/bin/ld: line 4: ` * Copyright (c) 1996,2007 Oracle. All rights reserved.' collect2: ld はステータス 2 で終了しました checked program was: /* begin */ 1: /*top*/ 2: int main() { return 0; } 3: int t() { pcap_open_live(); return 0; } /* end */ ------------------------------------------------------------------------------------------------------------ ------=_Part_13301_12794232.1220092810805--