编译命令
gcc -g connect_db.c -L/usr/lib/mysql -lmysqlclient -lz
注意:
如果 /tmp/ccTGmMS21.o: In function 'main':
/tmp/ccTGmMS21.o(.text+0x11): undefined reference to 'mysql_init'
那么参数增加-L参数
如果 /usr/lib/mysql/libmysqlclient.a(my_compress.o): In function 'my_uncompress':
my_compress.o(.text+0xaa): undefined reference to `uncompress'
那么增加-lz参数
如下问题,也是加上-lz:
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `my_uncompress':
my_compress.c:(.text+0x60): undefined reference to `uncompress'
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `my_compress_alloc':
my_compress.c:(.text+0x102): undefined reference to `compress'
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `my_compress':
my_compress.c:(.text+0x1ae): undefined reference to `compress'
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `unpackfrm':
my_compress.c:(.text+0x2bc): undefined reference to `uncompress'
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `packfrm':
my_compress.c:(.text+0x3bb): undefined reference to `compress'
collect2: ld returned 1 exit status
如下:
gcc -g connect_db.c -L/usr/lib/mysql -lmysqlclient -lz
注意:
如果 /tmp/ccTGmMS21.o: In function 'main':
/tmp/ccTGmMS21.o(.text+0x11): undefined reference to 'mysql_init'
那么参数增加-L参数
如果 /usr/lib/mysql/libmysqlclient.a(my_compress.o): In function 'my_uncompress':
my_compress.o(.text+0xaa): undefined reference to `uncompress'
那么增加-lz参数
如下问题,也是加上-lz:
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `my_uncompress':
my_compress.c:(.text+0x60): undefined reference to `uncompress'
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `my_compress_alloc':
my_compress.c:(.text+0x102): undefined reference to `compress'
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `my_compress':
my_compress.c:(.text+0x1ae): undefined reference to `compress'
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `unpackfrm':
my_compress.c:(.text+0x2bc): undefined reference to `uncompress'
/usr/local/mysql/lib/mysql//libmysqlclient.a(my_compress.o): In function `packfrm':
my_compress.c:(.text+0x3bb): undefined reference to `compress'
collect2: ld returned 1 exit status
如下:
g++ -o out mysql_fetch_rows.cpp str.cpp str.h -I/usr/local/mysql/include/mysql/ -L/usr/local/mysql/lib/mysql/ -lmysqlclient -lz
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/3919/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表