2009年2月16日

[mysql 14722] CentOSでの静的リンクについて

こんにちは。やまです。

MySQLのコンパイルについてご助言を頂きたくメールしました。

MySQLはCentOS 5.2 の yum でインストールしました。
バージョンは
$ mysql --version
mysql Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (i686) using

readline 5.0
となっています。

静的リンクでプログラムをコンパイルしたいと思っていますが
以下のような状態で通りません。

$ gcc -o hoge hoge.o -L/lib -L/usr/lib -L/usr/local/lib
-L/usr/lib/mysql -L/home/yama/src/lib -static -lhttpaccess -lssl -lnsl
-lcrypt -lcrypto -lgssapi_krb5 -lcom_err -lk5crypto -lresolv -ldl
-lkrb5support -lselinux -lsepol -lhpdf -lpng -lz -lm -lmysqlclient
/usr/lib/mysql/libmysqlclient.a(mf_pack.o): In function `unpack_dirname':
(.text+0x5d0): warning: Using 'getpwnam' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/lib/mysql/libmysqlclient.a(libmysql.o): In function `read_user_name':
(.text+0x55df): warning: Using 'getpwuid' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/lib/mysql/libmysqlclient.a(mf_pack.o): In function `unpack_dirname':
(.text+0x5df): warning: Using 'endpwent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/lib/mysql/libmysqlclient.a(my_gethostbyname.o): In function
`my_gethostbyname_r':
(.text+0x30): warning: Using 'gethostbyname_r' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/lib/mysql/libmysqlclient.a(libmysql.o): In function
`mysql_server_init':
(.text+0x51e5): warning: Using 'getservbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/lib/mysql/libmysqlclient.a(client.o): In function
`mysql_close_free_options':
(.text+0xd3d): undefined reference to `SSL_CTX_free'
/usr/lib/mysql/libmysqlclient.a(client.o): In function
`mysql_get_ssl_cipher':
(.text+0x1041): undefined reference to `SSL_get_current_cipher'
/usr/lib/mysql/libmysqlclient.a(client.o): In function `mysql_real_connect':
(.text+0x397c): undefined reference to `SSL_get_peer_certificate'
/usr/lib/mysql/libmysqlclient.a(client.o): In function `mysql_real_connect':
(.text+0x3990): undefined reference to `X509_get_subject_name'
/usr/lib/mysql/libmysqlclient.a(client.o): In function `mysql_real_connect':
(.text+0x39a4): undefined reference to `X509_NAME_oneline'
/usr/lib/mysql/libmysqlclient.a(client.o): In function `mysql_real_connect':
(.text+0x39ac): undefined reference to `X509_free'
/usr/lib/mysql/libmysqlclient.a(client.o): In function
`mysql_get_ssl_cipher':
(.text+0x104a): undefined reference to `SSL_CIPHER_get_name'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `report_errors':
(.text+0x45): undefined reference to `ERR_get_error_line_data'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslconnect':
(.text+0xc3): undefined reference to `SSL_new'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslconnect':
(.text+0xd7): undefined reference to `SSL_clear'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslconnect':
(.text+0xdf): undefined reference to `SSL_get_session'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslconnect':
(.text+0xee): undefined reference to `SSL_SESSION_set_timeout'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslconnect':
(.text+0xfc): undefined reference to `SSL_set_fd'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslconnect':
(.text+0x104): undefined reference to `SSL_connect'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslconnect':
(.text+0x172): undefined reference to `SSL_free'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslaccept':
(.text+0x1f3): undefined reference to `SSL_new'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslaccept':
(.text+0x207): undefined reference to `SSL_clear'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslaccept':
(.text+0x20f): undefined reference to `SSL_get_session'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslaccept':
(.text+0x21e): undefined reference to `SSL_SESSION_set_timeout'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslaccept':
(.text+0x22c): undefined reference to `SSL_set_fd'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslaccept':
(.text+0x234): undefined reference to `SSL_accept'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `sslaccept':
(.text+0x2a2): undefined reference to `SSL_free'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `vio_ssl_close':
(.text+0x2d8): undefined reference to `SSL_shutdown'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `vio_ssl_delete':
(.text+0x312): undefined reference to `SSL_free'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `vio_ssl_write':
(.text+0x361): undefined reference to `SSL_write'
/usr/lib/mysql/libmysqlclient.a(viossl.o): In function `vio_ssl_read':
(.text+0x381): undefined reference to `SSL_read'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`report_errors':
(.text+0x25): undefined reference to `ERR_get_error_line_data'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x99): undefined reference to `SSL_CTX_new'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0xbc): undefined reference to `SSL_CTX_set_cipher_list'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0xd9): undefined reference to `SSL_CTX_load_verify_locations'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0xfb): undefined reference to `SSL_CTX_use_certificate_file'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x125): undefined reference to `SSL_CTX_use_PrivateKey_file'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x135): undefined reference to `SSL_CTX_check_private_key'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x142): undefined reference to `DH_new'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x166): undefined reference to `BN_bin2bn'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x185): undefined reference to `BN_bin2bn'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x1bb): undefined reference to `SSL_CTX_ctrl'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x1c3): undefined reference to `DH_free'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x1da): undefined reference to `SSL_load_error_strings'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x1eb): undefined reference to `SSL_library_init'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x1f0): undefined reference to `OPENSSL_add_all_algorithms_noconf'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x206): undefined reference to `SSL_CTX_set_default_verify_paths'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x21d): undefined reference to `SSL_CTX_free'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x2bd): undefined reference to `DH_free'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLFd':
(.text+0x2d6): undefined reference to `SSL_CTX_free'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLAcceptorFd':
(.text+0x328): undefined reference to `TLSv1_server_method'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLAcceptorFd':
(.text+0x36f): undefined reference to `SSL_CTX_ctrl'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLAcceptorFd':
(.text+0x389): undefined reference to `SSL_CTX_set_verify'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLAcceptorFd':
(.text+0x39f): undefined reference to `SSL_CTX_set_session_id_context'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`vio_verify_callback':
(.text+0x3dd): undefined reference to `X509_STORE_CTX_get_current_cert'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`vio_verify_callback':
(.text+0x3e5): undefined reference to `X509_get_subject_name'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`vio_verify_callback':
(.text+0x3f9): undefined reference to `X509_NAME_oneline'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`vio_verify_callback':
(.text+0x426): undefined reference to `X509_STORE_CTX_get_error'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`vio_verify_callback':
(.text+0x42e): undefined reference to `X509_STORE_CTX_get_error_depth'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`vio_verify_callback':
(.text+0x447): undefined reference to `X509_get_issuer_name'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`vio_verify_callback':
(.text+0x45b): undefined reference to `X509_NAME_oneline'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLConnectorFd':
(.text+0x486): undefined reference to `TLSv1_client_method'
/usr/lib/mysql/libmysqlclient.a(viosslfactories.o): In function
`new_VioSSLConnectorFd':
(.text+0x4c5): undefined reference to `SSL_CTX_set_verify'
/usr/lib/mysql/libmysqlclient.a(my_compress.o): In function `my_uncompress':
(.text+0x60): undefined reference to `uncompress'
/usr/lib/mysql/libmysqlclient.a(my_compress.o): In function
`my_compress_alloc':
(.text+0x102): undefined reference to `compress'
collect2: ld はステータス 1 で終了しました
make: *** [nc_entry.cgi] エラー 1

素人考えながらCentOSのrpm作成時にMySQLをコンパイルした際のオプションで
SSLなどを指定しているからだと思いますが、いったい何のライブラリが
不足しているのかが分かりません。

-static を外すとコンパイルは通り、lddで確認すると以下のように
ライブラリがリンクされています。

$ gcc -o hoge hoge.o -L/lib -L/usr/lib -L/usr/local/lib
-L/usr/lib/mysql -L/home/yama/src/lib -lhttpaccess -lssl -lnsl -lcrypt
-lcrypto -lgssapi_krb5 -lcom_err -lk5crypto -lresolv -ldl -lkrb5support
-lselinux -lsepol -lhpdf -lpng -lz -lm -lmysqlclient
$ ldd nc_entry.cgi
linux-gate.so.1 => (0x00126000)
libssl.so.6 => /lib/libssl.so.6 (0x00ba2000)
libnsl.so.1 => /lib/libnsl.so.1 (0x006ee000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x007a7000)
libcrypto.so.6 => /lib/libcrypto.so.6 (0x0083c000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x009ae000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x004da000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00a73000)
libresolv.so.2 => /lib/libresolv.so.2 (0x007db000)
libdl.so.2 => /lib/libdl.so.2 (0x00624000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00b88000)
libselinux.so.1 => /lib/libselinux.so.1 (0x0066c000)
libsepol.so.1 => /lib/libsepol.so.1 (0x00686000)
libhpdf-2.1.0.so => /usr/local/lib/libhpdf-2.1.0.so (0x00f12000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x002a6000)
libz.so.1 => /usr/lib/libz.so.1 (0x006ce000)
libm.so.6 => /lib/libm.so.6 (0x0062a000)
libmysqlclient.so.15 => /usr/lib/mysql/libmysqlclient.so.15
(0x00be9000)
libc.so.6 => /lib/libc.so.6 (0x004df000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x009de000)
libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x00831000)
/lib/ld-linux.so.2 (0x004bc000)

これを元に
# yum install mysql-devel
# yum install openssl-devel
# yum install libgcrypt-devel
# yum install gnu-crypto
# yum install libgssapi-devel
# yum install bind-libbind-devel
# yum install krb5-devel
# yum install libselinux-devel
# yum install libsepol-devel
# yum install libpng-devel
# yum install libz-devel
# yum install libm-devel
# yum install glibc-devel
# yum install gnutls-devel

などをインストールしたのですがコンパイルの結果は最初のエラーメッセージと
同じものが表示され事態は改善しません。

どうすれば静的リンクが可能になるでしょうか?

すいません、よろしくお願い致します。

--------------------------------------
Power up the Internet with Yahoo! Toolbar.
http://pr.mail.yahoo.co.jp/toolbar/


投稿者 xml-rpc : 2009年2月16日 10:02
役に立ちました?:
過去のフィードバック 平均:(0) 総合:(0) 投票回数:(0)
本記事へのTrackback: http://hoop.euqset.org/blog/mt-tb2006.cgi/82227
トラックバック
コメント
コメントする




画像の中に見える文字を入力してください。