undefined reference to `mysql_init'
MySQL関連のライブラリが見つからないというエラーだが、-lmysqlclientは指定してあるし、ちょっとよく分からない。
最初はmysql_configの出力するコンパイラ・リンカのパラメーターと、自分のMakefileとで、にらめっこ。
-lmysqlclientは最後に付けたほうがいいらしい。
- MySQL :: MySQL 5.1 リファレンスマニュアル :: B.1.3.1 Problems Linking to the MySQL Client Library
http://dev.mysql.com/doc/refman/5.1/ja/link-errors.html
-lmysqlclient をリンカのパラメーターの最初の方で指定していたら以下のようなエラーになる。
undefined reference to `mysql_init' undefined reference to `mysql_real_connect' undefined reference to `mysql_stmt_init'
しかし、-lmysqlclient を最後に指定したら以下のようなエラーになる。これでようやく不足のライブラリが分かった。
undefined reference to `dlclose' undefined reference to `dlopen' undefined reference to `pthread_getspecific' undefined reference to `pthread_mutexattr_init'