linux下的C语言开发(makefile编写)
来源:互联网 发布:mac怎么下b站视频 知乎 编辑:程序博客网 时间:2024/06/05 07:27
--------转自平凡的程序员
对于程序设计员来说,makefile是我们绕不过去的一个坎。可能对于习惯Visual C++的用户来说,是否会编写makefile无所谓。毕竟工具本身已经帮我们做好了全部的编译流程。但是在Linux上面,一切变得不一样了,没有人会为你做这一切。编代码要靠你,测试要靠你,最后自动化编译设计也要靠你自己。想想看,如果你下载了一个开源软件,却因为自动化编译失败,那将会在很大程度上打击你学习代码的自信心了。所以,我的理解是这样的。我们要学会编写makefile,至少会编写最简单的makefile。
首先编写add.c文件,
- #include "test.h"
- #include <stdio.h>
- int add(int a, int b)
- {
- return a + b;
- }
- int main()
- {
- printf(" 2 + 3 = %d\n", add(2, 3));
- printf(" 2 - 3 = %d\n", sub(2, 3));
- return 1;
- }
- #include "test.h"
- int sub(int a, int b)
- {
- return a - b;
- }
- #ifndef _TEST_H
- #define _TEST_H
- int add(int a, int b);
- int sub(int a, int b);
- #endif
- test: add.o sub.o
- gcc -o test add.o sub.o
- add.o: add.c test.h
- gcc -c add.c
- sub.o: sub.c test.h
- gcc -c sub.c
- clean:
- rm -rf test
- rm -rf *.o
0 0
- linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- 【转】 linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- linux下的C语言开发(makefile编写)
- Linux下C语言开发(Makefile编写)
- Linux下的C语言开发(Makefile编写)
- Linux下C语言编译基础及makefile的编写
- Linux下的C语言学习之Makefile编写
- Linux下C语言编译基础及makefile的编写
- Linux下C语言编程基础知识--gcc编译器的使用、MakeFile文件的编写
- iOS开发:iOS TableViewCell自定义分割线
- Linux命令TR
- 【OC刨根问底】-Runtime简单粗暴理解
- Fragment的使用
- JAVA语言中的引用类型
- linux下的C语言开发(makefile编写)
- iOS storyboard约束加载webView自适应高度
- PL/SQL对象
- Percona Toolkit
- Android NFC智能卡介绍
- PHP文件夹文件拷贝/复制函数 dir_copy($src = '', $dst = '')
- iOS 代码添加约束—VFL (AutoLayout)
- EasyUI - datagrid中单元格里编辑控件的单击事件如何获取当前行的index
- php匹配图片、视频文件、音乐文件的正则表达式