免费注册 查看新帖 |

Chinaunix

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

[FreeBSD] 我编译不了iconv的程序,求助 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-12-18 22:11 |只看该作者 |倒序浏览
iconv装在FB6.2

  1. pkg_info | grep "iconv"
  2. libiconv-1.9.2_2    A character set conversion library
复制代码


我先是用#include <sys/iconv.h>
编译提示:

  1. cc -O2 -fno-strict-aliasing -pipe   main.c  -o main
  2. In file included from main.c:3:
  3. /usr/include/sys/iconv.h:94: error: syntax error before '*' token
  4. *** Error code 1
复制代码



然后我又改成#include "/usr/local/include/iconv.h"
编译提示:

  1. cc -O2 -fno-strict-aliasing -pipe   main.c  -o main
  2. main.c: In function `main':
  3. main.c:49: warning: passing arg 2 of `libiconv' from incompatible pointer type
  4. /var/tmp//ccvgGXSD.o(.text+0x98): In function `main':
  5. : undefined reference to `libiconv_open'
  6. /var/tmp//ccvgGXSD.o(.text+0xbe): In function `main':
  7. : undefined reference to `libiconv'
  8. /var/tmp//ccvgGXSD.o(.text+0x138): In function `main':
  9. : undefined reference to `libiconv'
  10. /var/tmp//ccvgGXSD.o(.text+0x1af): In function `main':
  11. : undefined reference to `libiconv_close'
  12. /var/tmp//ccvgGXSD.o(.text+0x1f0): In function `main':
  13. : undefined reference to `libiconv_close'
  14. *** Error code 1
复制代码

论坛徽章:
2
亥猪
日期:2014-03-19 16:36:35午马
日期:2014-11-23 23:48:46
2 [报告]
发表于 2006-12-18 22:47 |只看该作者
没有链接库
cc -O2 -fno-strict-aliasing -pipe -lxxx main.c  -o main
xxx大致应该是iconv

论坛徽章:
0
3 [报告]
发表于 2006-12-19 15:36 |只看该作者
还是不行啊

gcc -O2 -fno-strict-aliasing -pipe -L /usr/obj/usr/src/sys/GOD/modules/usr/src/sys/modules/libiconv/ -liconv ~/test/iconv/main.c -o ~/test/iconv/code
/home/soj/test/iconv/main.c: In function `main':
/home/soj/test/iconv/main.c:49: warning: passing arg 2 of `libiconv' from incompatible pointer type
/usr/bin/ld: cannot find -liconv

论坛徽章:
0
4 [报告]
发表于 2006-12-19 15:50 |只看该作者

回复 3楼 balabalacha 的帖子

-I/usr/local/include -L/usr/local/lib/ -liconv

论坛徽章:
0
5 [报告]
发表于 2006-12-19 20:42 |只看该作者
嗨,终于行了,谢谢楼上.

BTW:为什么我用
#include <iconv.h>  报没有此文件
或者#include <sys/iconv.h>  则是报

  1. In file included from main.c:3:
  2. /usr/include/sys/iconv.h:94: error: syntax error before '*' token
  3. main.c: In function `main':
  4. main.c:16: error: syntax error before "c_pt"
  5. main.c:36: error: `iconv_t' undeclared (first use in this function)
  6. main.c:36: error: (Each undeclared identifier is reported only once
  7. main.c:36: error: for each function it appears in.)
  8. main.c:36: error: `c_pt' undeclared (first use in this function)
复制代码

论坛徽章:
0
6 [报告]
发表于 2006-12-29 18:26 |只看该作者
因为Freebsd自己也有iconv库。
而你实际在想要用的是gnu的iconv库。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP