static linkããã«ããã£ã¦ã®åæ©ã諸注æï¼ãã¡ãããã®ã§å¿ èªï¼ã¯ [twitter:@sonots] ããã®
ãåç §ãã¦ãã ããã
ããã§ã¯DBD::mysqlããã«ãããéã®ãªãã·ã§ã³ã®ã¿è¨ãã¾ãã
http://dev.mysql.com/downloads/mysql/ ãããã¦ã³ãã¼ãã§ããrpm
- MySQL-client-5.6.21-1.el6.x86_64.rpm
- MySQL-devel-5.6.21-1.el6.x86_64.rpm
- MySQL-shared-5.6.21-1.el6.x86_64.rpm
ã®å ´åã
$ ldconfig -p | grep libmysqlclient libmysqlclient.so.18 (libc6,x86-64) => /usr/lib64/libmysqlclient.so.18 libmysqlclient.so (libc6,x86-64) => /usr/lib64/libmysqlclient.so $ rpm -ql MySQL-devel | grep libmysqlclient.a /usr/lib64/mysql/libmysqlclient.a $ mysql_config --libs -L/usr/lib64 -lmysqlclient -lpthread -lm -lrt -ldl
ããããæãã®æ§æã«ãªã£ã¦ããã®ã§ã
- /usr/lib64ã®ä»£ããã«libmysqlclient.aããã/usr/lib64/mysqlã«ã©ã¤ãã©ãªãã¹ãéã
- libstdc++ããªã³ã¯ãã
ããããã«ããã®ããã«
$ mysql_config --libs | sed -e 's@-L/usr/lib64@-L/usr/lib64/mysql@' -e 's@$@ -lstdc++@' -L/usr/lib64/mysql -lmysqlclient -lpthread -lm -lrt -ldl -lstdc++
ãã¾ãã
ã½ã¼ã¹ãå±éãã¦Makefile.PLã使ã£ã¦ãã«ãããå ´åã¯ã--libsã«ãããæå®ããã°ããã§ãã
$ perl Makefile.PL --libs="$(mysql_config --libs | sed -e 's@-L/usr/lib64@-L/usr/lib64/mysql@' -e 's@$@ -lstdc++@')" $ make $ ldd blib/arch/auto/DBD/mysql/mysql.so linux-vdso.so.1 => (0x00007fff9a52a000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3434572000) libm.so.6 => /lib64/libm.so.6 (0x00007f34342ee000) librt.so.1 => /lib64/librt.so.1 (0x00007f34340e5000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f3433ee1000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f3433ccb000) libc.so.6 => /lib64/libc.so.6 (0x00007f3433936000) /lib64/ld-linux-x86-64.so.2 (0x00007f3434d84000) # âlibmysqlclient.so ã dynamic linkãã¦ããªã $ perl -Iblib/lib -Iblib/arch -MDBD::mysql -e 1 # âã¡ããã¨ã¢ã¸ã¥ã¼ã«ããã¼ãã§ãã $ sudo make install
ã¡ãªã¿ã« -lstdc++ ãã¦ããªãå ´åã¯ãã®ããã«ã¢ã¸ã¥ã¼ã«ã®ãã¼ãã§å¤±æãã¾ãã
$ perl -Iblib/lib -Iblib/arch -MDBD::mysql -e 1 Can't load 'blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: __cxa_pure_virtual at /usr/lib64/perl5/DynaLoader.pm line 200. at - line 0 Compilation failed in require. BEGIN failed--compilation aborted.
cpanmã§ã¤ã³ã¹ãã¼ã«ããå ´åã¯ã--configure-args="--libs=..." ã«æå®ããã°ããã§ãã
$ mylib=$(mysql_config --libs | sed -e 's@-L/usr/lib64@-L/usr/lib64/mysql@' -e 's@$@ -lstdc++@') $ cpanm -n DBD::mysql --configure-args="--libs='${mylib}'"
Oracle謹製ã®rpmã«ã¯å
ç¨æ¸ãã http://dev.mysql.com/downloads/mysql/ ã§é
å¸ãã¦ãããã®ã®ä»ã«ãyumã¬ãã¸ããªã§é
å¸ãã¦ãããã®ãããã¾ãã
- http://dev.mysql.com/downloads/repo/yum/
- http://repo.mysql.com/yum/
- http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/
- mysql-community-client-5.6.21-2.el6.x86_64.rpm
- mysql-community-common-5.6.21-2.el6.x86_64.rpm
- mysql-community-devel-5.6.21-2.el6.x86_64.rpm
- mysql-community-libs-5.6.21-2.el6.x86_64.rpm
ãªãã両è ã§ã¯ã©ã¤ãã©ãªãã¡ã¤ã«ã®é ç½®ãç°ãªã£ã¦ããã®ã§æ°ãã¤ãã¦ãã ããã
ãã®ããã«ã
$ ldconfig -p | grep libmysqlclient libmysqlclient.so.18 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.18 libmysqlclient.so (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so $ rpm -ql mysql-community-devel | grep libmysqlclient.a /usr/lib64/mysql/libmysqlclient.a $ mysql_config --libs -L/usr/lib64/mysql -lmysqlclient -lpthread -lm -lrt -ldl
yumã§é å¸ãã¦ããrpmã®ã¯libmysqlclient.soã.aãåããã£ã¬ã¯ããª/usr/lib64/mysqlã«ããã¾ãã
ãã®ã¾ã¾ã§ã¯static linkã§ããªãã®ã§ã*.aãå¥ã®ãã£ã¬ã¯ããªã«ã³ãã¼ãã¦ãããã«ã©ã¤ãã©ãªãã¹ãéãã¦ãã«ãããªãã¨ããã¾ããã
$ mkdir /tmp/oreno-lib $ cp /usr/lib64/mysql/*.a /tmp/oreno-lib/ $ mysql_config --libs -L/usr/lib64/mysql -lmysqlclient -lpthread -lm -lrt -ldl $ mylib="-L/tmp/oreno-lib -lmysqlclient -lpthread -lm -lrt -ldl -lstdc++" $ perl Makefile.PL --libs="${mylib}" OR $ cpanm -n DBD::mysql --configure-args="--libs='${mylib}'"