linux c语言编程环境搭建(linux下c语言编程 从零开始开始)
[color=#295200][size=14pt][b]linux c语言编程环境搭建(linux下c语言编程 从零开始开始)[/b][/size][/color] linux c语言编程环境搭建需要如下软件和开发包:
terminal 终端
gcc //编译器
cpp
libgcc
libc6 //库 标准库 数学函数 在libc.so.6目录下
binutils //连接工具
/usr/bin/size
/usr/bin/ar
/usr/bin/objdump
/usr/bin/strings
/usr/bin/as
/usr/bin/ld
locals //提供本地支持
libc6-dev //c共享库 头文件
glibc-doc //文档
glibc-doc-reference //参考手册
manpages-dev //man 函数用法
make //维护源代码
make-doc
gdb //调试程序
vim //编辑器
indent //格式化源代码
简单的hell world代码编写执行过程:
root@xuanfei-desktop:~/cpropram# vi 1.c //编辑代码
root@xuanfei-desktop:~/cpropram# indent -kr 1.c //格式化代码
root@xuanfei-desktop:~/cpropram# cat 1.c //查看代码
#include <stdio.h>
int main(int argc, char **agv)
{
printf("hello\n");
return 0;
}
root@xuanfei-desktop:~/cpropram# ls //查看不录下的文件
1.c txt
root@xuanfei-desktop:~/cpropram# gcc -Wall 1.c //编译1.c文件
root@xuanfei-desktop:~/cpropram# ls //再次查看
1.c 1.c~ a.out txt
root@xuanfei-desktop:~/cpropram# ./a.out //运行编译后生成的二进制可执行文件
hello
argc argv的用法
实例演示一
root@xuanfei-desktop:~/cpropram# cat 1.c
#include <stdio.h>
int main(int argc, char **argv)
{
printf("hello\n");
if (argc < 2)
return -1;
else {
printf("argc=%s argv[0]=%s argv[1]=%s\n", argv, argv[0], argv[1]);
}
return 0;
}
实例演示二、
root@xuanfei-desktop:~/cpropram# cat argc.c
#include <stdio.h>
int main(int argc, char **argv)
{
int i;
for (i = 0; i < argc; i++)
printf("argv [%d] is %s\n", i, argv[i]);
return 0;
}
root@xuanfei-desktop:~/cpropram# ./a.out my name is xuanfei
argv [0] is ./a.out
argv [1] is my
argv [2] is name
argv [3] is is
argv [4] is xuanfei
如上内容根据周立发linux视频教程所做的笔录,为了方便大家理解,建议大家可以到下面的连接下载观看。
[size=2][color=#0001ff][url=http://blog.chinaunix.net/u/29321/showart_343791.html][size=10pt]周立发 linux 视频教程下载(不定期持续更新)[/size][/url][/color][/size][/i][table=98%,rgb(153, 204, 153)][tr][td]
[/td][/tr][tr][td]
[/td][/tr][/table][i][color=#ff0102]如以上内容有误或有不足之处,望朋友能给予意见或者建议!谢谢:)weblog: xuanfei.cublog.cn
[/color]
[color=#ff0102]
[/color][/i]
[[i] 本帖最后由 悬非 于 2007-7-22 11:16 编辑 [/i]]
页:
[1]