免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 1726 | 回复: 11
打印 上一主题 下一主题

GCC报错,如何解决呢? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-03 17:03 |只看该作者 |倒序浏览
[root@localhost root]# gcc -I/usr/include/mysql/ -L/usr/lib/mysql -o mysql mysql.c -lmysqlclient

/usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0xf5): In function `my_compress_alloc':
: undefined reference to `compress'
/usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0x1a5): In function `my_uncompress':
: undefined reference to `uncompress'
collect2: ld returned 1 exit status


应该如何解决阿??谢谢大家了

论坛徽章:
0
2 [报告]
发表于 2006-08-03 17:30 |只看该作者
两个函数连接不到

论坛徽章:
1
射手座
日期:2013-09-30 15:24:05
3 [报告]
发表于 2006-08-03 18:01 |只看该作者
把你的源代码贴出来,你怎么用的system啊!

论坛徽章:
0
4 [报告]
发表于 2006-08-03 18:20 |只看该作者
我是楼主

  1. #include <stdio.h>
  2. #include <mysql.h>


  3. int main()
  4. {
  5.    MYSQL_RES  *result;
  6.    MYSQL_ROW  row;
  7.    MYSQL *connection,mysql;
  8.    int state;
  9.    /*连接MYSQL*/
  10.    mysql_init(&mysql);
  11.    connection = mysql_real_connect(&mysql,"127.0.0.0","root","157525","example",0,0,0);
  12.    /*检查连接错误*/
  13.    if(connection==NULL)
  14.    {
  15.         printf(mysql_error(&mysql));
  16.         return -1;
  17.    }
  18.    state = mysql_query(connection,"select * from phone");
  19.    if(state !=0)
  20.    {
  21.          printf(mysql_error(connection));
  22.          return -1;
  23.    }
  24.    /*开存储空间*/
  25.    result = mysql_store_result(connection);
  26.    printf("roes: %d\n",mysql_num_rows(result));
  27.    while((row = mysql_fetch_row(result)) !=NULL)
  28.    {
  29.          printf("id: %s ,val : %s\n",row[0]?row[0]:"NULL",row[1]?row[1]:"NULL");
  30.    }
  31.    mysql_free_result(result);
  32.    mysql_close(connection);
  33.    printf("ok,done\n");
  34. }
  35.    
  36.    
  37.    
复制代码

[ 本帖最后由 wanghi 于 2006-8-3 18:24 编辑 ]

论坛徽章:
0
5 [报告]
发表于 2006-08-03 18:31 |只看该作者
估计还有加个-lmy_compress
但不知道你有没有那个库

论坛徽章:
0
6 [报告]
发表于 2006-08-03 18:38 |只看该作者
楼上的帅哥,这个库是干嘛的啊??

论坛徽章:
0
7 [报告]
发表于 2006-08-03 19:18 |只看该作者
错误的意思是库mysqlclient.a中的模块my_compress.o中的函数my_compress_alloc中找不到调用的compress函数的代码

论坛徽章:
0
8 [报告]
发表于 2006-08-03 21:10 |只看该作者
加一个  -lz  就可以了!!

不过问一下这个参数是干嘛的?

论坛徽章:
0
9 [报告]
发表于 2006-08-03 22:17 |只看该作者
还是不够全面阿

论坛徽章:
0
10 [报告]
发表于 2006-08-04 10:14 |只看该作者
原帖由 wanghi 于 2006-8-3 21:10 发表
加一个  -lz  就可以了!!

不过问一下这个参数是干嘛的?

晕,原来是这个库中的函数
$ nm /usr/lib/libz.a |grep compress
compress.o:
000000c0 T compress
00000000 T compress2
00000000 T uncompress
000019a0 t compress_block
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP