超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
sunnyorc
帖子: 3
注册时间: 2009-09-26 10:16

超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#1

帖子 sunnyorc » 2009-09-26 11:13

因为计算需要运行一个linux下的程序,第一次使用Ubuntu,自己是电脑菜鸟,没有编程知识。敬请大家帮忙。

按照程序的manual

我输入>>gcc ssweep.c -o ssw -lm
得到结果:bash:swweep.c: command not found

请问-0和-lm是什么意思?
得到这个结果是什么意思?如何解决?
sunnyorc
帖子: 3
注册时间: 2009-09-26 10:16

Re: 超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#2

帖子 sunnyorc » 2009-09-26 11:43

此外,我运行sudo apt-get build-essential
显示:E:无效的操作 build-essential

怎么回事?
dbzhang800
帖子: 3182
注册时间: 2006-03-10 15:10
来自: xi'an China
联系:

Re: 超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#3

帖子 dbzhang800 » 2009-09-26 11:46

同一个原因,你输错了。从哪儿看到了,可以复制粘贴的
头像
slax
帖子: 1099
注册时间: 2009-08-17 3:52

Re: 超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#4

帖子 slax » 2009-09-26 12:47

1:gcc ssweep.c -o ssw -lm 得到结果:bash:swweep.c: command not found :

you must add you directory or first cd to your directory, for example,

代码: 全选

gcc ~/ssweep.c -o ssw -lm 

or

代码: 全选

cd ~/ 
gcc ssweep.c -o ssw -lm 
2:sudo apt-get install build-essential
头像
slax
帖子: 1099
注册时间: 2009-08-17 3:52

Re: 超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#5

帖子 slax » 2009-09-26 12:50

of course,you can use some IDE like codeblocks anjuta and so on.
sunnyorc
帖子: 3
注册时间: 2009-09-26 10:16

Re: 超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#6

帖子 sunnyorc » 2009-09-26 13:30

thank you very much.

For the first question. I have cd to my directory and input right command. but the result is the same.

For the second question. slax is right. thanks
头像
jioyo源
帖子: 3476
注册时间: 2008-10-08 13:48

Re: 超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#7

帖子 jioyo源 » 2009-09-26 13:44

:em20 先找本基础教程 看一下,然后再有不懂的再来论坛问……
--------------------------------------
论坛精华贴全集:http://forum.ubuntu.org.cn/viewtopic.php?f=48&t=199845
book:http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=198286
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

Re: 超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#8

帖子 BigSnake.NET » 2009-09-26 13:47

sunnyorc 写了:thank you very much.

For the first question. I have cd to my directory and input right command. but the result is the same.

For the second question. slax is right. thanks
你不是把那个 >> 也输入了吧 =。= 。。
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
slax
帖子: 1099
注册时间: 2009-08-17 3:52

Re: 超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#9

帖子 slax » 2009-09-26 13:49

sunnyorc 写了:thank you very much.

For the first question. I have cd to my directory and input right command. but the result is the same.

For the second question. slax is right. thanks
莫非你和我一样,刚才scim崩溃了? :em04
头像
slax
帖子: 1099
注册时间: 2009-08-17 3:52

Re: 超级菜鸟第一次用gcc有问题请教,在线等回答,谢谢

#10

帖子 slax » 2009-09-26 13:57

BigSnake.NET 写了:
sunnyorc 写了:thank you very much.

For the first question. I have cd to my directory and input right command. but the result is the same.

For the second question. slax is right. thanks
你不是把那个 >> 也输入了吧 =。= 。。
bash:swweep.c: command not found

好像gcc 被忽略了,莫非是真的把>>给打进去了?

将swweep.c 重命名 为 main.c 再将下面的文字复制成 makefile 文件放在同目录下,在终端下 make 运行

代码: 全选

# 源文件
c_source_files := main.c
c_header_files := 

# 输出文件
executable_files := main
object_files := $(patsubst %.c, %.o, $(c_source_files))

CFLAGS +=
LDLIBS +=

CFLAGS ?= -g -O0
CFLAGS += -Wall -Wextra


.PHONY: all
all: $(executable_files)
#------------------------------------
$(executable_files): $(object_files)
	$(LINK.o) $^ $(LDLIBS) -o $@
$(executable_files).o: $(c_source_files) $(c_header_files)
	$(COMPILE.c) $< -o $@
#--------------------------------------
# make clean
# 仅删除编译生成的.o文件,保留可执行文件和*.log
.PHONY: clean
clean:
	$(RM) $(object_files)
#------------------------------------
# make distclean
# 删除*.o、可执行文件以及*.log
.PHONY: distclean
distclean:
	$(RM) $(object_files)
	$(RM) $(executable_files)
	$(RM) $(log_files)
回复