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 ...
随机推荐
- PHP常用正则验证
手机号,身份证,ip验证 //正则验证手机号 正确返回 true function preg_mobile($mobile) { if(preg_match("/^1[34578]\d{9} ...
- 20145229 《Java程序设计》第10周学习总结
20145229 <Java程序设计>第10周学习总结 教材学习内容总结 Java网络编程技术 数据交换 在计算机网络中,现在命名IP地址的规定是IPv4协议,该协议规定每个IP地址由4个 ...
- [算法]Rotate Array
You may have been using Java for a while. Do you think a simple Java array question can be a challen ...
- 算法(Algorithms)第4版 练习 1.5.8
假设原id数组: 0 1 1 4 4 8 6 1 8 0 输入p = 5, q = 7 则输出结果会出错,最终为: 0 1 1 4 4 1 6 1 8 0 因为当id[p](id[5] = 8)被赋值 ...
- 使用 sqoop 将 hive 数据导出到 mysql (export)
使用sqoop将hive中的数据传到mysql中 1.新建hive表 hive> create external table sqoop_test(id int,name string,age ...
- BioNLP概述
BioNLP概述 工具: GENIA Tagger:GENIA Tagger是一个主要应用于生物医学文本领域的词性标注和浅层语法分析工具,GENIA Tagger在GENIA语料上的词性标记性能F-s ...
- C++难点的一些总结
一. C++成员函数的重载 C++中的成员函数有四种,分别是普通成员函数,virtual虚函数,const成员函数. (1) void func(int a); (2) virtual void fu ...
- Codeforces 463D Gargari and Permutations:隐式图dp【多串LCS】
题目链接:http://codeforces.com/problemset/problem/463/D 题意: 给你k个1到n的排列,问你它们的LCS(最长公共子序列)是多长. 题解: 因为都是1到n ...
- SESSION应用的一个场合
Session其实指的就是访问者从到达某个特定主页到离开为止的那段时间.每 一访问者都会单独获得一个Session.在Web应用程序中,当一个用户访问该应用 时,Session类型的变量可以供这个用户 ...
- Hibernate学习---第八节:继承关系的映射配置
1.单表继承 (1).实体类,代码如下: package learn.hibernate.bean; import java.util.Date; /** * 持久化类设计 * 注意: * 持久化类通 ...