为什么我用不了gcc

OOo,TeX,KO,ABI,GIMP,Picasa,ProE,QCAD,Inkscape,Kicad,Eagle
ShengC
帖子: 11
注册时间: 2005-10-14 9:00

为什么我用不了gcc

#1

帖子 ShengC » 2005-10-18 19:58

代码: 全选

shengc@ubuntu:~$ cat > Hello.c << EOF
> int main()
> {
> printf("Helo!");
> return 1;
> }
> EOF
shengc@ubuntu:~$ gcc Hello.c
Hello.c: 在函数 ‘main’ 中:
Hello.c:3: 警告:内建函数 ‘printf’ 不兼容的隐式声明
/usr/bin/ld: crt1.o: No such file: 没有那个文件或目录
collect2: ld 返回 1
shengc@ubuntu:~$
还要设置写什么东西?
以前都是系统已经预装好了gcc,所以现在。。。
头像
yonsan
帖子: 887
注册时间: 2005-07-01 18:56
来自: 广州市

#2

帖子 yonsan » 2005-10-18 20:25

:o 呵, 楼主强吖!

代码: 全选

#include <stdio.h>
都没写上!
I will be back!
ShengC
帖子: 11
注册时间: 2005-10-14 9:00

#3

帖子 ShengC » 2005-10-18 21:21

yonsan 写了::o 呵, 楼主强吖!

代码: 全选

#include <stdio.h>
都没写上!
我在redhat9中输入的结果:

代码: 全选

[root@localhost root]# cat > temp.c << EOF
> int main()
> {
> printf("Hello");
> return 1;
> }
> EOF
[root@localhost root]# gcc -o temp temp.c
[root@localhost root]# ./temp
Hello
[root@localhost root]#
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#4

帖子 eexpress » 2005-10-18 23:09

那就是你的redhat不符合游戏规则。
● 鸣学
头像
yonsan
帖子: 887
注册时间: 2005-07-01 18:56
来自: 广州市

#5

帖子 yonsan » 2005-10-19 0:25

:o 是吖, 居然没有加 -Wall 参数都没警告一下!!
I will be back!
Zer4tul
帖子: 106
注册时间: 2005-08-09 10:14

#6

帖子 Zer4tul » 2005-10-19 1:08

版本的问题吧……
ShengC
帖子: 11
注册时间: 2005-10-14 9:00

#7

帖子 ShengC » 2005-10-19 12:22

你们的都可以用吗

我就是sudo apt-get install gcc
还要设置或者装什么其他的东西吗?

代码: 全选

shengc@ubuntu:~$ cat > temp.c << EOF
> #include <stdio.h>
> int main()
> {
> printf("Hello!\n");
> return 1;
> }
> EOF
shengc@ubuntu:~$ gcc -o temp temp.c
temp.c:1:19: error: stdio.h: 没有那个文件或目录
temp.c: 在函数 ‘main’ 中:
temp.c:4: 警告:内建函数 ‘printf’ 不兼容的隐式声明
shengc@ubuntu:~$

头像
glade
帖子: 1383
注册时间: 2005-10-21 16:57

#8

帖子 glade » 2005-10-23 15:14

我也遇到相同的问题
一个Hello world这样的小程序也编译不了
头像
catinsnow
帖子: 773
注册时间: 2005-08-02 7:23
来自: 上海

#9

帖子 catinsnow » 2005-10-23 15:35

我这里是可以的啊。用的是GCC3.4
Ubuntu Intrepid
#P4 2.4
P4 2.4C
#1024MB
2048MB
#120G
500G+120G
Nvidia FX5700
#ATI9100 --拆了,受不了ATI的驱动.
头像
glade
帖子: 1383
注册时间: 2005-10-21 16:57

#10

帖子 glade » 2005-10-23 15:45

晕~~怎么回事
我照着
http://www.ubuntu.org.cn/support/docume ... chterm=gcc
上面的做了
装了GCC 4.0
编译的时候总是出现
warning: incompatible implicit declaration of......
这样的错误
zhanglyl
帖子: 14
注册时间: 2005-09-02 8:05

#11

帖子 zhanglyl » 2005-10-23 15:45

你用的gcc 4吗?
zhanglyl
帖子: 14
注册时间: 2005-09-02 8:05

#12

帖子 zhanglyl » 2005-10-23 15:53

是没有安装库文件的缘故啊!请参照下面的方法即可解决。
(Ubuntu 5.10)
1) sudo apt-get install gcc

2)sudo apt-get install libc6-dev

OK!
头像
glade
帖子: 1383
注册时间: 2005-10-21 16:57

#13

帖子 glade » 2005-10-23 16:04

libc6-dev已经装过了
aa.c

代码: 全选

#include <stdio.h>
main()
{
    printf("Hello World");
}
cc aa.c
编译通过
但是执行a.out的时候提示
a.out: error while loading shared libraries: tenv: cannot open shared object file: No such file or directory
怎么设置
头像
glade
帖子: 1383
注册时间: 2005-10-21 16:57

#14

帖子 glade » 2005-10-23 16:12

按照linuxdown README的说明
出现很多错误

代码: 全选

root@Lee:~/linuxdown-1.2.0# make
gcc -lpthread   -c -o Dandi.o Dandi.c
gcc: -lpthread: linker input file unused because linking not done
gcc -lpthread   -c -o DownFromFTP.o DownFromFTP.c
DownFromFTP.c: In function ‘DownLoadFtp’:
DownFromFTP.c:55: warning: incompatible implicit declaration of built-in functio n ‘strlen’
DownFromFTP.c:77: warning: incompatible implicit declaration of built-in functio n ‘strstr’
gcc: -lpthread: linker input file unused because linking not done
gcc -lpthread   -c -o DownFromHTTP.o DownFromHTTP.c
DownFromHTTP.c: In function ‘DownLoadHttp’:
DownFromHTTP.c:44: warning: incompatible implicit declaration of built-in functi on ‘strlen’
gcc: -lpthread: linker input file unused because linking not done
gcc -lpthread   -c -o DandiBase.o DandiBase.c
gcc: -lpthread: linker input file unused because linking not done
gcc -lpthread   -c -o GenFunc.o GenFunc.c
GenFunc.c:126: error: static declaration of ‘hash’ follows non-static declaratio n
GenFunc.h:82: error: previous declaration of ‘hash’ was here
GenFunc.c:297: error: static declaration of ‘call_hash’ follows non-static decla ration
GenFunc.h:83: error: previous declaration of ‘call_hash’ was here
GenFunc.c: In function ‘call_hash’:
GenFunc.c:326: warning: incompatible implicit declaration of built-in function ‘ memcpy’
.
.
.

此处省略n行
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#15

帖子 eexpress » 2005-10-23 16:39

tenv?
这是什么库啊。
warning: incompatible implicit declaration of built-in function ‘ memcpy’
这个是没有linux-headers
● 鸣学
回复