因此,在使用GCC在Ubuntu 12.04 LTS x64下使用mysql ++编译程序时出现此错误。详细说明:
/usr/lib/i386-linux-gnu/libmysqlclient.a(client_plugin.c.o): In function add_plugin:
(.text+0x253): undefined reference to dlclose
/usr/lib/i386-linux-gnu/libmysqlclient.a(client_plugin.c.o): In function mysql_client_plugin_deinit:
(.text+0x2c7): undefined reference to dlclose
/usr/lib/i386-linux-gnu/libmysqlclient.a(client_plugin.c.o): In function mysql_load_plugin_v:
(.text+0x524): undefined reference to dlopen
/usr/lib/i386-linux-gnu/libmysqlclient.a(client_plugin.c.o): In function mysql_load_plugin_v:
(.text+0x54a): undefined reference to dlsym
/usr/lib/i386-linux-gnu/libmysqlclient.a(client_plugin.c.o): In function mysql_load_plugin_v:
(.text+0x67f): undefined reference to dlerror
/usr/lib/i386-linux-gnu/libmysqlclient.a(client_plugin.c.o): In function mysql_load_plugin_v:
(.text+0x695): undefined reference to dlclose
我安装了:libmysql ++ - 3,libmysqlclient18和libmysqlclient18-dev,libdml3和libdml3-dev 库按以下顺序链接:
/usr/lib/libmysqlpp.a
/usr/lib/i386-linux-gnu/libdl.a
/usr/lib/i386-linux-gnu/libmysqlclient.a
并且链接器包含我拥有的目录:
/usr/lib
/usr/lib/i386-linux-gnu
答案 0 :(得分:2)
将评论作为答案。所以它不会迷路:
您必须在-ldl
之后链接-lmysqlclient
。链接顺序很重要。