logo
code:Haemophilus influenzae

ここに書かれていることは無保証です。同じことを行って問題が発生しても、 龍義は責任をとりません。

2004年4月1日

戻る

cygwin にて OpenSSH のコンパイル

cygwin にて OpenSSH をコンパイルしたときのメモ。結果は失敗に終わってます。
なぜコンパイルをしようかと考えのかと言うと、OpenSSH での chroot の
実験をしたかったから。具体的には http://chrootssh.sourceforge.net/index.php
からダウンロードできる patch の動作を試したかったため。

OpenSSH 3.8p1 の cygwin へのインストールをするべく、とりあえず、 
OpenSSL 0.9.7d をダウンロードしてきて、インストールした(これは、cygwin の
setup.exe より openssl-devel を選択してインストールすることにより
不要になります)。

# tar xvfz openssl-0.9.7d.tar.gz
# cd openssl-0.9.7d
# ./config
# make
# make build-shared
# make install
# cp *.dll /bin
# cp *.dll.a /lib

OpenSSH 3.8p1 をダウンロードしてきて make してみた。

# tar xvfz openssh-3.8p1.tar.gz
# cd openssh-3.8p1
# ./configure
# make
〜snip〜
../openbsd-compat/getrrsetbyname.h:57:26: arpa/nameser.h: No such file or directory
/usr/include/resolv.h:61:26: sys/bitypes.h: No such file or directory
/usr/include/resolv.h:68:26: arpa/nameser.h: No such file or directory
/usr/include/resolv.h:328: error: syntax error before "ns_tsig_key"
/usr/include/resolv.h:472: error: syntax error before "ns_tsig_key"
/usr/include/resolv.h:474: error: syntax error before "ns_class"
/usr/include/resolv.h:477: error: syntax error before "ns_class"

だそうで。 cygwin の setup を実行して、 bind 周りのものが
インストールできるかどうか調べてみたが、無いようである。仕方がないので、
isc から bind 8.4.4 をダウンロードしてきた。

# wget ftp://ftp.isc.org/isc/bind/src/8.4.4/bind-src.tar.gz
# tar xvfz bind-src.tar.gz
# cd src/include
# make install

include ファイルは /usr/local/bind/include にインストールされたようである。
Makefile と openbsd-compat/Makefile の CPPFLAGS に -I/usr/local/bind/include を
追加した。OpenSSH のディレクトリに戻って make の再実行。

/usr/local/bind/include/arpa/inet.h:68:26: sys/bitypes.h: No such file or directory
/usr/local/bind/include/netdb.h:98:26: sys/bitypes.h: No such file or directory
/usr/local/bind/include/arpa/nameser.h:62:26: sys/bitypes.h: No such file or directory
/usr/local/bind/include/resolv.h:61:26: sys/bitypes.h: No such file or directory
../openbsd-compat/fake-rfc2553.h:123: error: redefinition of `struct addrinfo'

あらら。もう一度、 bind のディレクトリに行って、

# find ./ -name bitypes.h

とすると、 src/port/cygwin/include/sys に発見したので、

# cd src/port/cygwin/include
# make install

とした。これで再び OpenSSH の make を実行した。

../openbsd-compat/fake-rfc2553.h:123: error: redefinition of `struct addrinfo'

は消えてくれない。config.h の

/* #undef HAVE_STRUCT_ADDRINFO */

を

#define HAVE_STRUCT_ADDRINFO 1

に変更した。これで、 make 実行。最後の最後で、

gcc -o ssh.exe ssh.o readconf.o clientloop.o sshtty.o sshconnect.o sshconnect1.o
 sshconnect2.o -L. -Lopenbsd-compat/ -L/usr/local/ssl/lib  -lssh -lopenbsd-compa
t -lcrypto -lz  /usr/lib/textmode.o -lcrypt
./libssh.a(channels.o)(.text+0x1fda): In function `channel_decode_socks4':
/tmp/openssh/openssh-3.8p1/channels.c:924: undefined reference to `___inet_ntoa'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x266): In function `check_nt_auth':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:146: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x360): In function `check_ntsec':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:172: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x497): In function `register_9x_service':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:221: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x4ab):/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:223: undefined reference to `_LoadLibraryA'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x4bf):/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:225: undefined reference to `_GetProcAddress'
openbsd-compat//libopenbsd-compat.a(fake-rfc2553.o)(.text+0xbe): In function `ssh_getnameinfo':
/tmp/openssh/openssh-3.8p1/openbsd-compat/fake-rfc2553.c:58: undefined reference to `___inet_ntoa'
openbsd-compat//libopenbsd-compat.a(fake-rfc2553.o)(.text+0x310): In function `ssh_getaddrinfo':
/tmp/openssh/openssh-3.8p1/openbsd-compat/fake-rfc2553.c:172: undefined reference to `___inet_aton'
openbsd-compat//libopenbsd-compat.a(fake-rfc2553.o)(.text+0x369):/tmp/openssh/openssh-3.8p1/openbsd-compat/fake-rfc2553.c:187: undefined reference to `___inet_aton'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0xa9): In function `getrrsetbyname':
/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:190: undefined reference to `__res'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0xc2):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:202: undefined reference to `__res'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0xe7):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:206: undefined reference to `___res_query'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x320):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:218: undefined reference to `___res_init'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x331):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:191: undefined reference to `__res'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x611): In function `parse_dns_qsection':
/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:436: undefined reference to `___dn_expand'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x74e): In function `parse_dns_rrsection':
/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:482: undefined reference to `___dn_expand'
collect2: ld returned 1 exit status
make: *** [ssh.exe] Error 1

となった。う〜ん。 config.h の

/* #undef BROKEN_INET_NTOA */

を

#define BROKEN_INET_NTOA 1

として、再度 make の実行。

gcc -o ssh.exe ssh.o readconf.o clientloop.o sshtty.o sshconnect.o sshconnect1.o
 sshconnect2.o -L. -Lopenbsd-compat/ -L/usr/local/ssl/lib  -lssh -lopenbsd-compa
t -lcrypto -lz  /usr/lib/textmode.o -lcrypt
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x266): In function `check_nt_auth':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:146: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x360): In function `check_ntsec':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:172: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x497): In function `register_9x_service':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:221: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x4ab):/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:223: undefined reference to `_LoadLibraryA'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x4bf):/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:225: undefined reference to `_GetProcAddress'
openbsd-compat//libopenbsd-compat.a(fake-rfc2553.o)(.text+0x310): In function `ssh_getaddrinfo':
/tmp/openssh/openssh-3.8p1/openbsd-compat/fake-rfc2553.c:172: undefined reference to `___inet_aton'
openbsd-compat//libopenbsd-compat.a(fake-rfc2553.o)(.text+0x369):/tmp/openssh/openssh-3.8p1/openbsd-compat/fake-rfc2553.c:187: undefined reference to `___inet_aton'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0xa9): In function `getrrsetbyname':
/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:190: undefined reference to `__res'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0xc2):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:202: undefined reference to `__res'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0xe7):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:206: undefined reference to `___res_query'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x320):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:218: undefined reference to `___res_init'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x331):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:191: undefined reference to `__res'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x611): In function `parse_dns_qsection':
/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:436: undefined reference to `___dn_expand'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x74e): In function `parse_dns_rrsection':
/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:482: undefined reference to `___dn_expand'
collect2: ld returned 1 exit status
make: *** [ssh.exe] Error 1

エラーが1つだけ減った気もしないこともないが。config.h の下記の部分をコメントに
してみた。

#define HAVE_INET_ATON 1
#define HAVE_INET_NTOA 1

から、

/* #define HAVE_INET_ATON 1 */
/* #define HAVE_INET_NTOA 1 */

にして、再実行。

gcc -o ssh.exe ssh.o readconf.o clientloop.o sshtty.o sshconnect.o sshconnect1.o
 sshconnect2.o -L. -Lopenbsd-compat/ -L/usr/local/ssl/lib  -lssh -lopenbsd-compa
t -lcrypto -lz  /usr/lib/textmode.o -lcrypt
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x266): In function `check_nt_auth':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:146: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x360): In function `check_ntsec':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:172: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x497): In function `register_9x_service':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:221: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x4ab):/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:223: undefined reference to `_LoadLibraryA'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x4bf):/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:225: undefined reference to `_GetProcAddress'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0xa9): In function `getrrsetbyname':
/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:190: undefined reference to `__res'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0xc2):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:202: undefined reference to `__res'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0xe7):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:206: undefined reference to `___res_query'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x320):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:218: undefined reference to `___res_init'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x331):/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:191: undefined reference to `__res'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x611): In function `parse_dns_qsection':
/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:436: undefined reference to `___dn_expand'
openbsd-compat//libopenbsd-compat.a(getrrsetbyname.o)(.text+0x74e): In function `parse_dns_rrsection':
/tmp/openssh/openssh-3.8p1/openbsd-compat/getrrsetbyname.c:482: undefined reference to `___dn_expand'
collect2: ld returned 1 exit status
make: *** [ssh.exe] Error 1

bind の library を入れてみる。

# src/lib
# make
# cp libbind.a /usr/lib/

で、config.h の HAVE_INET_ATON, HAVE_INET_NTOA のコメントを解除して、
コンパイルする際に -lbind を付けて make してみた。

gcc -o ssh.exe ssh.o readconf.o clientloop.o sshtty.o sshconnect.o sshconnect1.o
 sshconnect2.o -L. -Lopenbsd-compat/ -L/usr/local/ssl/lib  -lssh -lopenbsd-compa
t -lcrypto -lz  /usr/lib/textmode.o -lcrypt -lbind
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x266): In function `check_nt_auth':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:146: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x360): In function `check_ntsec':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:172: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x497): In function `register_9x_service':
/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:221: undefined reference to `_GetVersion'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x4ab):/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:223: undefined reference to `_LoadLibraryA'
openbsd-compat//libopenbsd-compat.a(bsd-cygwin_util.o)(.text+0x4bf):/tmp/openssh/openssh-3.8p1/openbsd-compat/bsd-cygwin_util.c:225: undefined reference to `_GetProcAddress'
collect2: ld returned 1 exit status

半分ぐらい無くなったが、あとはどうすれば良いものやら…。


by Tatsuyoshi
since 2003