易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux GCC make文件的写法4 清晰版

包含3个文件夹,和一个文件Makefile
目录组织结构如下:
Makefile
inc/hello.h
main/main.c
src/hello.c
Makefile文件在外面,这样生成的.o和可执行文件都在外面,clean之后会很干净,结构清晰
文件内容如下:
Makefile(之所以用大写,因为make可以识别Makefile和makefile,用大写可以鲜明一些)::
# String declaration
objects = main.o hello.o
# Command
app : $(objects)
cc -o app $(objects)
main.o : main/main.c hello.h
cc -c main/main.c
hello.o : src/hello.c stdio.h
cc -c src/hello.c
# Search paths
vpath %.h /usr/include inc
# Clean the intermediate files
.PHONY : clean
clean :
rm app $(objects)

hello.h:
void hello(char name[]);
main.c:
#include <stdio.h>
#include "../inc/hello.h"
// The second hello.h should in ""
int main()
{
hello("GCC");
printf("Haha Linux Ubuntu!\n");
return 0;
}
其中,第二个包含文件,hello.h,必须要用"",如果用<>则gcc只会到系统目录下去搜索,不会到本当前目录下搜索
就是""在用户目录下,<>在系统目录下,这个在windows上不严格, 在linux里似乎很严格
hello.c:
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}


相关文档:

如何从Windows轻松过渡到Linux?

引:
Linux操作系统是由Linus Torvalds先生在1991年创建的,之后不断获得互联网上众多程序员的自愿支持,经过十几年的发展,如今已经成为继Windows之后的第二大电脑操作系统软件。
你是否对Linux有充分的了解呢?作为一种平台,Linux首先获得了沉溺于某种癖好之士和黑客们的
青睐。Linux操作系统是由Linus
Torvalds先生 ......

linux vi 命令大全

进入vi的命令
vi filename :打开或新建文件,并将光标置于第一行首
vi +n filename :打开文件,并将光标置于第n行首
vi + filename :打开文件,并将光标置于最后一行首
vi +/pattern filename:打开文件,并将光标置于第一个与pattern匹配的串处
vi -r filename :在上次正用vi编辑时发生系统崩溃,恢复filename
vi ......

linux试题

我为什么发表不了文章呢?
1. 在Linux系统中,以 文件 方式访问设备 。
2. Linux内核引导时,从文件 /etc/fstab 中读取要加载的文件系统。
3. Linux文件系统中每个文件用 i节点 来标识。
4. 全部磁盘块由四个部分组成,分别为引导块 、专用块 、 i节点表块 和数据存储块。
5. 链接分为: 硬链接 和 符号链接 。
6. 超 ......

Linux GCC make文件的写法2

文件在两个文件夹:
inc/hello.h
main/hello.c, main.c, Makefile
文件内容:
hello.h
void hello(char name[]);

hello.c
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}

main.c
#include <stdio.h>
#include "../inc/hello.h"
// The second
int main( ......

Linux GCC make文件的写法3

 包含3个文件夹
目录组织结构如下:
inc/hello.h
main/main.c, Makefile
src/hello.c
文件内容如下:
hello.h:
void hello(char name[]);
main.c:
#include <stdio.h>
#include "../inc/hello.h"
// The second hello.h should in ""
int main()
{
hello("GCC");
printf("Haha Linux Ub ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号