makefile基本语法
多文件编程的小例子
功能:在main.c里面调用其他两个源文件里面的函数,然后输出字符串。
1、main.c
#include"mytool1.h"
#include"mytool2.h"
int main(int argc,char* argv[])
{
mytool1_printf("hello.");
mytool2_print("hello");
return 1;
}
2、 mytool1.h mytool1.c
//mytool1.h
#ifndef _MYTOOL_1_H
#define _MYTOOL_1_H
void mytool1_printf(char* print_str);
#endif
//mytool1.c
#include"mytool1.h"
#include<stdio.h>
void mytool1_printf(char* print_str)
{
printf("This is mytool1 print %s\n",print_str);
}
3、 mytool2.h mytool2.c
//mytool2.h
#ifndef _MYTOOL_2_H
#define _MYTOOL_2_h
void mytool2_print(char* print_str);
#endif
//mytool2.c
#include "mytool2.h"<br><br>#include<stdio.h>
void mytool2_print(char* print_str)
{
printf("This is mytool2 print %s\n",print_str);
}
makefile:
cc=gcc
target=main
obj=main.o mytool1.o mytool2.o
$(target):$(obj)
$(cc) $(obj) -o $(target)
main.o:main.c
$(cc) -c main.c
mytool1.o:mytool1.c
$(cc) -c mytool1.c
mytool2.o:mytool2.c
$(cc) -c mytool2.c
clean : $(RM) *.o $(target)
注:Makefile有三个非常有用的变量。分别是$@,$^,$<代表的意义分别是:
$@--目标文件,$^--所有的依赖文件,$<--第一个依赖文件。
makefile基本语法的更多相关文章
- makefile的语法及写法(二)
3 Makefile书写规则 -------------------------------------------------------------------------------- 规则包 ...
- makefile的语法及写法
什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉得要作一个好的和professional的程序员,makefile还是要 ...
- Makefile基础语法
Makefile的作用 如果没有Makefile,每次修改源代码后,如果要重新编译代码,都要输入编译命令,当源代码很多时,效率很底下. 基本格式 target: componsnts TAB rule ...
- Makefile 基础语法
1.. specify the directores , i not specified , search current directory put every folder into a list ...
- Makefile
原文链接:http://www.orlion.ga/816/ 一.基本规则 对于一个拥有多个文件的c项目,编译时可能是这样的指令: gcc main.c stack.c -o main 如果编译之后又 ...
- C C++ 语法
非常酷的网站: http://yige.org/cpp/defined_data_types.php 在Linux下有一个目录/proc/$(pid),这个目录保存了进程号为pid的进程运行时的所有信 ...
- C++学习笔记25:makefile文件2
Makefile文件语法 行解析:命令按行解析 命令行的行首字符为Tab键,其他行的行首字符不得为Tab键,但可以使用多个空格缩进 换行:命令太长时,行尾使用"\"换行 注释:行首 ...
- 转载-------makefile 使用总结
转载自:http://www.cnblogs.com/wang_yb/p/3990952.html 1. Makefile 简介 Makefile 是和 make 命令一起配合使用的. 很多大型项目的 ...
- (二)我的Makefile学习冲动&&编译过程概述
前言 一 年轻的冲动 二 学习曲线 1 Makefile基本语法 2 bash基础 3 world 三 编译过程概述 1 主机预装工具 2 编译host工具 3 编译交叉工具链 4 编译内核模块 5 ...
随机推荐
- 扣出thinkphp数据库操作类
假如你是一位thinkphp的使用者,想必你会觉得thinkphp操作数据库非常方便.现在在你面前有一个非常小的作业,小到完全没有必要用thinkphp去完成它.但是你又觉得不用thinkphp的话, ...
- Hive与Hbase关系整合
近期工作用到了Hive与Hbase的关系整合,虽然从网上参考了很多的资料,但是大多数讲的都不是很细,于是决定将这块知识点好好总结一下供大家分享,共同掌握! 本篇文章在具体介绍Hive与Hbase整合之 ...
- Data Structure Graph: cycle in a directed graph
geeks上的解答复杂了些,用回溯就行了 #include <iostream> #include <vector> #include <algorithm> #i ...
- Data Structure Binary Tree: Check if a given Binary Tree is SumTree
http://www.geeksforgeeks.org/check-if-a-given-binary-tree-is-sumtree/ #include <iostream> #inc ...
- 【leetcode刷题笔记】Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- Python 3 并发编程多进程之守护进程
Python 3 并发编程多进程之守护进程 主进程创建守护进程 其一:守护进程会在主进程代码执行结束后就终止 其二:守护进程内无法再开启子进程,否则抛出异常:AssertionError: daemo ...
- hihocoder 第五十二周 高斯消元·二【高斯消元解异或方程 难点【模板】】
题目地址:http://hihocoder.com/contest/hiho57/problem/1 输入 第1..5行:1个长度为6的字符串,表示该行的格子状态,1表示该格子是亮着的,0表示该格子是 ...
- Luogu-2600 [ZJOI2008]瞭望塔
把地面看成半平面,能看到所有位置的点所在的区域即为半平面的交 因为分段函数的极值只会在转折处或边界取到,所以对于半平面上和地面上的每一个交点都求一下距离就好了 #include<cmath> ...
- 学习docker可能会用到的参考
局域网部署Docker--从无到有创建自己的Docker私有仓库 http://lib.csdn.net/base/docker 正在刷(学习)一遍官方文档,上面是一些其他可能用到的资料,是在解决自己 ...
- bootstrap中使用日历控件
在bootstrap中使用日历控件可以参照以下资料: http://www.bootcss.com/p/bootstrap-datetimepicker/index.htm 以下是参照此资料自己做的一 ...