mysql编译错误:undefined reference to `dlclose' Linux

一、错误现象

      在linux编译mysql代码,出现如下错误:

/usr/lib64/mysql/libmysqlclient.a(client_plugin.c.o): In function `add_plugin':
/export/home/pb2/build/sb_0-9651683-1372794821.34/rpm/BUILD/mysql-5.6.12/mysql-5.6.12/sql-common/client_plugin.c:178: undefined reference to `dlclose'
/usr/lib64/mysql/libmysqlclient.a(client_plugin.c.o): In function `mysql_client_plugin_deinit':
/export/home/pb2/build/sb_0-9651683-1372794821.34/rpm/BUILD/mysql-5.6.12/mysql-5.6.12/sql-common/client_plugin.c:280: undefined reference to `dlclose'
/usr/lib64/mysql/libmysqlclient.a(client_plugin.c.o): In function `mysql_load_plugin_v':
/export/home/pb2/build/sb_0-9651683-1372794821.34/rpm/BUILD/mysql-5.6.12/mysql-5.6.12/sql-common/client_plugin.c:367: undefined reference to `dlopen'
/export/home/pb2/build/sb_0-9651683-1372794821.34/rpm/BUILD/mysql-5.6.12/mysql-5.6.12/sql-common/client_plugin.c:396: undefined reference to `dlsym'
/export/home/pb2/build/sb_0-9651683-1372794821.34/rpm/BUILD/mysql-5.6.12/mysql-5.6.12/sql-common/client_plugin.c:387: undefined reference to `dlerror'
/export/home/pb2/build/sb_0-9651683-1372794821.34/rpm/BUILD/mysql-5.6.12/mysql-5.6.12/sql-common/client_plugin.c:399: undefined reference to `dlclose'
collect2: ld returned 1 exit status

二、原因

      要对使用dlopen的文件进行编译时,需要加上 -ldl。


三、解决办法

      在Makefile中,加上-ldl。

      LINK_OPTIONS := \
            -lstdc++ \
            -lrt \
            -lpthread \
            -ldl 

你可能感兴趣的:(mysql编译错误:undefined reference to `dlclose' Linux)