各位前辈:
小弟是新手,最近用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的版本可以在线升级吗?
在网上查了好久的资料也没找到原因,所以只能来这里想各位请教了,万分感谢!