免费注册 查看新帖 |

Chinaunix

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

gcc 编译时怎么连接程序库 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-17 14:40 |只看该作者 |倒序浏览
程序库: conv.a
gcc: gcc-3.2.2-5

我查到用 -L 参数, 不过我编译时提示: gcc: argument to `-L' is missing. 我应该怎么办? 谢谢!

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
2 [报告]
发表于 2006-08-17 14:56 |只看该作者
-L 的参数缺失。
意思是说,-L 选项要求有个参数,但是你没给它。

论坛徽章:
0
3 [报告]
发表于 2006-08-17 15:02 |只看该作者
#gcc -o count count.c -l src/libfileconv.a

输出:
/usr/bin/ld: cannot find -lsrc/libfileconv.a
collect2: ld returned 1 exit status

是上面这样(小写的 L),麻烦再给看一眼.

用 -L (大写的 L)参数的时候出来一堆错误:
/tmp/ccqJEm8x.o(.text+0x33): In function `main':
: undefined reference to `GetFileType'
/tmp/ccqJEm8x.o(.text+0x65): In function `main':
: undefined reference to `ConvFileToTxt'
/tmp/ccqJEm8x.o(.text+0x77): In function `main':
: undefined reference to `fcountwords'
/tmp/ccqJEm8x.o(.text+0xa1): In function `main':
: undefined reference to `fcountwords'

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2006-08-17 15:04 |只看该作者
gcc -o count count.c -lfileconv  -L./src

论坛徽章:
0
5 [报告]
发表于 2006-08-17 15:28 |只看该作者
看输出好象是找到库文件了,不过又出来更多的错误.

[root@localhost lib]# gcc -o count count.c -lfileconv  -L./src
./libfileconv.a(excel.o)(.text+0x4507): In function `output_formatted_data':
: undefined reference to `__swbuf'
./libfileconv.a(excel.o)(.text+0x4785): In function `PrintFloatComma':
: undefined reference to `_DefaultRuneLocale'
./libfileconv.a(excel.o)(.text+0x47ad): In function `PrintFloatComma':
...

论坛徽章:
0
6 [报告]
发表于 2006-08-17 17:14 |只看该作者
我也遇到这样的问题 我把编译语句写成:gcc count.c conv.a -o count 就OK了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP