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 ...
随机推荐
- 第13条:合理利用try/expect/else/finally结构中的每个代码块
核心知识点: (1)无论try块是否发生异常,都可以使用try/finally复合语句中地finally块来执行清理工作. (2)顺利运行try块后,若想使某些操作能在finally块地清理代码之前执 ...
- 简化Hadoop命令
1. 安装客户端(通过端用户可以方便的和集群交互) 2. 简化Hadoop命令 修改~/.bashrcalias hadoop='/home/work/hadoop/client/hadoop-cli ...
- [转] 在Mac上搭建React Native开发环境
原文链接: http://blog.csdn.net/xiangzhihong8/article/details/53914336 概述 前面我们介绍过在window环境下开发React Native ...
- BZOJ 3890 [Usaco2015 Jan]Meeting Time:拓扑图dp
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3890 题意: 给你一个有向图,n个点(n <= 100),m条边. 且所有的边都是从 ...
- web项目中添加logger日志
在项目中添加log4j.xml文件 log4j.xml文件 <?xml version="1.0" encoding="UTF-8" ?><! ...
- wp8使用现有sqlite数据库
就是把现有文件转移到隔离空间即可 代码如下 private async void CopyDB() { StorageFile fage = await Appli ...
- struts2 框架 的环境搭建 与配置
一,Struts2简介: 1,来由:Struts(金属支架),在程序中表示起支撑作用的通用程序代码,Struts2是在Struts1框架的基础上融合了WebWork优秀框架升级得到的. 2,解释:St ...
- Java--异常与字符串
1.处理异常 try-catch以及try-catch-finally try{ //一些会抛出的异常 }catch(Exception e){ //处理该异常的代码块 }catch(Exceptio ...
- ADO:连接,执行语句与关闭(sql server数据库)
一,身份验证: sql server数据库连接身份验证有两种:windows身份验证和SQL Server身份验证 windows验证:是使用windows的安全子系统对用户连接进行有效性验证.(个人 ...
- 洛谷【P1177】【模板】快速排序
题目传送门:https://www.luogu.org/problemnew/show/P1177 快排是一种对于冒泡排序的优化. 对于区间\([l,r]\),我们选择一个键值\(k\),让比\(k\ ...