| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5053 人关注过本帖
标题:gcc编译报错。不明白gcc-c 能通过,gcc-o就报错
只看楼主 加入收藏
hyj0616
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2016-8-1
结帖率:66.67%
收藏
已结贴  问题点数:20 回复次数:4 
gcc编译报错。不明白gcc-c 能通过,gcc-o就报错
cust@gnu:~$ cd /home/cust/metric_PAS_64
cust@gnu:~/metric_PAS_64$ gcc -o chunk.o
gcc: fatal error: no input files
compilation terminated.
cust@gnu:~/metric_PAS_64$
2016-09-08 22:09
azaza
Rank: 2
等 级:论坛游民
帖 子:2
专家分:20
注 册:2016-9-11
收藏
得分:20 
linux 不看后缀的,所以
gcc -o chunk.o

gcc -o chunk是一样的,都进行了编译链接,但是没有指定源文件,所以出错了。应该像这样子:
gcc chunk.c -o chunk
如果只想生产目标文件而不进行链接的话应该是这样的:
gcc -c chunk.c

2016-09-11 16:24
hyj0616
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2016-8-1
收藏
得分:0 
回复 2楼 azaza
如果是gcc chunk.c -o chunk 报错
如果是gcc -c chunk.c 编译通过
2016-09-13 09:51
hyj0616
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2016-8-1
收藏
得分:0 
回复 2楼 azaza
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/tmp/ccCMOWgJ.o: In function `file_chunk_winDis':
chunk.c:(.text+0x11c): undefined reference to `md5'
chunk.c:(.text+0x128): undefined reference to `md5_2_feature64'
chunk.c:(.text+0x148): undefined reference to `vec_push_back'
/tmp/ccCMOWgJ.o: In function `file_chunk_cdc':
chunk.c:(.text+0x4da): undefined reference to `adler32_checksum'
chunk.c:(.text+0x50e): undefined reference to `adler32_rolling_checksum'
chunk.c:(.text+0x5b7): undefined reference to `md5'
chunk.c:(.text+0x5c6): undefined reference to `md5_2_feature64'
chunk.c:(.text+0x5e6): undefined reference to `vec_push_back'
chunk.c:(.text+0x650): undefined reference to `md5'
chunk.c:(.text+0x65f): undefined reference to `md5_2_feature64'
chunk.c:(.text+0x67f): undefined reference to `vec_push_back'
chunk.c:(.text+0x86e): undefined reference to `md5'
chunk.c:(.text+0x87d): undefined reference to `md5_2_feature64'
chunk.c:(.text+0x89d): undefined reference to `vec_push_back'
/tmp/ccCMOWgJ.o:(.data+0x10): undefined reference to `ELF_hash'
/tmp/ccCMOWgJ.o:(.data+0x30): undefined reference to `simple_hash'
/tmp/ccCMOWgJ.o:(.data+0x48): undefined reference to `RS_hash'
/tmp/ccCMOWgJ.o:(.data+0x60): undefined reference to `JS_hash'
/tmp/ccCMOWgJ.o:(.data+0x78): undefined reference to `PJW_hash'
/tmp/ccCMOWgJ.o:(.data+0x90): undefined reference to `ELF_hash'
/tmp/ccCMOWgJ.o:(.data+0xa8): undefined reference to `BKDR_hash'
/tmp/ccCMOWgJ.o:(.data+0xc0): undefined reference to `SDBM_hash'
/tmp/ccCMOWgJ.o:(.data+0xd8): undefined reference to `DJB_hash'
/tmp/ccCMOWgJ.o:(.data+0xf0): undefined reference to `AP_hash'
/tmp/ccCMOWgJ.o:(.data+0x108): undefined reference to `CRC_hash'
collect2: error: ld returned 1 exit status
2016-09-13 11:10
azaza
Rank: 2
等 级:论坛游民
帖 子:2
专家分:20
注 册:2016-9-11
收藏
得分:0 
回复 4楼 hyj0616
/usr/bin/ld程序是GCC的链接程序
链接错处建议检查几处
1.main函数是否已经有了,有没有把main写成了mian
2.有没有一些变量或者函数没定义就使用
3.使用了非gcc自带的库函数而在编译时没有加上路径
先想到这些,建议参考
http://
2016-10-08 12:20
快速回复:gcc编译报错。不明白gcc-c 能通过,gcc-o就报错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.047797 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved