求助:MYSQL程序链接静态库的问题

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
zcglaomao
帖子: 3
注册时间: 2008-11-25 10:22

求助:MYSQL程序链接静态库的问题

#1

帖子 zcglaomao » 2008-11-25 10:34

各位前辈:
小弟是新手,最近用C语言编写了个读取mysql数据库的程序,编写完后打算用静态编译的方式生成可可移植性高的可执行文件,我用的编译器是gcc4.2。
编译命令为:gcc -o service.exe linux_server_mysql.c -L/usr/lib -static -lmysqlclient -lz -lpthread,打算连接静态库libmysqlclient.a,但是编译总是出问题,提示如下:

/usr/lib/libmysqlclient.a(mf_pack.o): In function `unpack_dirname':
(.text+0x5b6): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

/usr/lib/libmysqlclient.a(libmysql.o): In function `read_user_name':
(.text+0x57ef): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

/usr/lib/libmysqlclient.a(mf_pack.o): In function `unpack_dirname':
(.text+0x5c5): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

/usr/lib/libmysqlclient.a(my_gethostbyname.o): In function `my_gethostbyname_r':
(.text+0x30): warning: Using 'gethostbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

/usr/lib/libmysqlclient.a(libmysql.o): In function `mysql_server_init':
(.text+0x6136): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

/usr/lib/libmysqlclient.a(my_compress.o): In function `my_uncompress':
(.text+0x60): undefined reference to `uncompress'

/usr/lib/libmysqlclient.a(my_compress.o): In function `my_compress_alloc':
(.text+0x102): undefined reference to `compress'

/usr/lib/libmysqlclient.a(libtaocrypt_la-dh.o): In function `TaoCrypt::(anonymous namespace)::DiscreteLogWorkFactor(unsigned int)':
(.text+0x9f): undefined reference to `pow'

/usr/lib/libmysqlclient.a(libtaocrypt_la-dh.o): In function `TaoCrypt::(anonymous namespace)::DiscreteLogWorkFactor(unsigned int)':
(.text+0xad): undefined reference to `log'

/usr/lib/libmysqlclient.a(libtaocrypt_la-dh.o): In function `TaoCrypt::(anonymous namespace)::DiscreteLogWorkFactor(unsigned int)':
(.text+0xc5): undefined reference to `pow'
collect2: ld returned 1 exit status

请问各位前辈,这是什么原因造成的?是不是我的GLIBC库版本(ubuntu6.06,glibc应该是2.3.6)不够?怎样才能够解决?另外ubuntu和glibc的版本可以在线升级吗?
在网上查了好久的资料也没找到原因,所以只能来这里想各位请教了,万分感谢!
wdf777
帖子: 11
注册时间: 2008-11-06 20:28

Re: 求助:MYSQL程序链接静态库的问题

#2

帖子 wdf777 » 2008-11-25 11:34

看来我是新手中的新手
zcglaomao
帖子: 3
注册时间: 2008-11-25 10:22

Re: 求助:MYSQL程序链接静态库的问题

#3

帖子 zcglaomao » 2008-11-25 16:01

搜索了一下,发现有几个朋友也遇见了该问题,但似乎都不知道该怎么解决,希望高手帮忙!
zcglaomao
帖子: 3
注册时间: 2008-11-25 10:22

Re: 求助:MYSQL程序链接静态库的问题

#4

帖子 zcglaomao » 2008-11-26 16:07

版主和各位高手没有遇见过这样的问题吗?没有确切答案的话有什么相关线索也可以提示一下小弟,先谢了。
marc2005
帖子: 1
注册时间: 2009-05-24 3:11

Re: 求助:MYSQL程序链接静态库的问题

#5

帖子 marc2005 » 2010-05-12 23:18

我最近也遇到这个问题,求助高人。

有没有人碰到类似情况的,我的 glibc 版本是 2.10,ubuntu 9.10,照理说应该没问题啊。
回复