分页: 1 / 1

vim菜鸟

发表于 : 2008-03-09 11:12
李伟武
在vim 下编写C程序
#include<stdio.h>
void main(void)
{
printf("ubuntu");
}
在命令模式下输入地:make
之后提示:make: *** 没有指明目标并且找不到 makefile。 停止。
这个问题怎么解决呀??

发表于 : 2008-03-09 11:29
dbzhang800
用make之前要先写makefile。

一个文件的话,直接gcc编译就好了
http://wiki.ubuntu.org.cn/gcchowto

别笑话

发表于 : 2008-03-09 11:34
李伟武
用gcc怎么编译呀?是直接在命令模式下输入:gcc吗?问题太菜了,别笑话哦!@

发表于 : 2008-03-09 11:56
newman0708
这样就可以了
$ gcc -o hello hello.c
chmod +x ./hello
./hello

Re: 别笑话

发表于 : 2008-03-09 12:34
dbzhang800
李伟武 写了:用gcc怎么编译呀?是直接在命令模式下输入:gcc吗?问题太菜了,别笑话哦!@
vim命令模式执行外部命令 加"!"

代码: 全选

:!gcc -Wall % -o %<

第一个C程序问题

发表于 : 2008-03-10 20:16
w3484732
我一直都不能完成最基本的C程序!
我想输入一个简单的C程序HELLO WORLD
是这样编译的:
#include <stdio.h>

int main()
{
printf("Hello, world!\n");
return 0;
}

存为并退出:hello.c
在终端输入:gcc -o hello.c vi.c回车
出现:
wangxuyuan@wangxuyuan-laptop:~$ gcc -o hello.c vi.c
gcc: vi.c:No such file or directory
gcc: 没有输入文件
wangxuyuan@wangxuyuan-laptop:~$

这是怎么回事阿,大家能看看我是那里出错了?
C程序我在很多地方找到的都不一样!这是怎么回事?
如:我在书上看到的:
#include<iostream>

int main()
{
std::cout<<"hello world!\n;
return 0;
}

Re: 第一个C程序问题

发表于 : 2008-03-10 20:48
dbzhang800
w3484732 写了:我一直都不能完成最基本的C程序!
我想输入一个简单的C程序HELLO WORLD
是这样编译的:
#include <stdio.h>

int main()
{
printf("Hello, world!\n");
return 0;
}

存为并退出:hello.c
在终端输入:gcc -o hello.c vi.c回车
出现:
wangxuyuan@wangxuyuan-laptop:~$ gcc -o hello.c vi.c
gcc: vi.c:No such file or directory
gcc: 没有输入文件
wangxuyuan@wangxuyuan-laptop:~$

这是怎么回事阿,大家能看看我是那里出错了?
C程序我在很多地方找到的都不一样!这是怎么回事?
如:我在书上看到的:
#include<iostream>

int main()
{
std::cout<<"hello world!\n;
return 0;
}
另一帖子中回复你了

Re: vim菜鸟

发表于 : 2008-03-13 10:05
diskdriver
李伟武 写了:在vim 下编写C程序
#include<stdio.h>
void main(void)
{
printf("ubuntu");
}
在命令模式下输入地:make
之后提示:make: *** 没有指明目标并且找不到 makefile。 停止。
这个问题怎么解决呀??
直接make + 文件名前部分(去掉".c")

Re: 第一个C程序问题

发表于 : 2008-04-12 12:51
Furson
w3484732 写了:我一直都不能完成最基本的C程序!
我想输入一个简单的C程序HELLO WORLD
是这样编译的:
#include <stdio.h>

int main()
{
printf("Hello, world!\n");
return 0;
}

存为并退出:hello.c
在终端输入:gcc -o hello.c vi.c回车
出现:
wangxuyuan@wangxuyuan-laptop:~$ gcc -o hello.c vi.c
gcc: vi.c:No such file or directory
gcc: 没有输入文件
wangxuyuan@wangxuyuan-laptop:~$

这是怎么回事阿,大家能看看我是那里出错了?
C程序我在很多地方找到的都不一样!这是怎么回事?
如:我在书上看到的:
#include<iostream>

int main()
{
std::cout<<"hello world!\n;
return 0;
}
wangxuyuan@wangxuyuan-laptop:~$ gcc -o hello.c vi.c

后面那个vi.c文件是干嘛的,应该把那个去掉就可以了吧。

发表于 : 2008-04-12 13:26
poet
最简单的 Makefile 写法:
假定你需要编译 hello.c

# Makefile 内容

all: hello

完了,就只需要一行代码,保存为 Makefile

然后可以在相同目录下使用 vi 里面的 make。

大多数情况下 Makefile 是比直接用 gcc 更方便的办法。

如果你编译的不是 hello.c 就把那个 hello 换成你需要的名字。

编译c程序,说没有stdio.h 这个文件

发表于 : 2008-09-17 22:20
guhuipaul
终端输入vi hello.c

#include <stdio.h>
int main()
{
printf("hello man\n");
return 0;
}
退出,保存
再输入gcc hello.c
结果输出下面的东东

hello.c:1:19: 错误: stdio.h:没有该文件或目录
hello.c: 在函数‘main’中:
hello.c:4: 警告: 内建函数 ‘printf’ 不兼容的隐式声明

我确保自己的gcc是有装,而且是新的,请问各位大哥是什么原因

发表于 : 2008-09-17 22:25
guhuipaul
找到答案了,抱歉,造成文字垃圾了

发表于 : 2008-09-17 22:52
xeoc
最佳解决办法看这里!把这个添加到vimrc里,按f5一切ok...

代码: 全选

" C的编译和运行
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc % -o %<"
exec "! ./%<"
endfunc