Linux makefile 教程 非常详细,且易懂 http://blog.csdn.net/liang13664759/article/details/1771246

//sort.c
#include <stdio.h>
#include <string.h> void swap(int* a, int* b);
int arry[] = {, , , ,}; void show(int * parry, int size)
{
int i = ;
printf("parry:");
for(i=; i<size; i++)
{
printf("%d ", parry[i]);
}
printf("\n");
} void sort(int* parry, int size)
{
int i, j;
int is_sort = ;
for(i = ; i < size - && !is_sort; i++)
{
for(j = ; j < size - - i; j++)
{
is_sort = ;
if(parry[j] > parry[j+])
{
is_sort = ;
swap(&parry[j], &parry[j+]);
}
}
}
} void old_sort(int* parry, int size)
{
int i, j; for(i = ; i< size - ; i++)
{
for(j = ; j< size- - i ; j++)
{
if(parry[j] > parry[j+])
{
swap(&parry[j], &parry[j+]);
} }
}
} void swap(int* a, int* b)
{
if(a== || b==)
{
return;
} *a = *a ^ *b;
*b = *a ^ *b;
*a = *a ^ *b;
} int func()
{
show(arry, );
sort(arry, );
show(arry, );
return ;
}
//main.c
#include <stdio.h>
int main()
{
printf("start main\n");
func();
return ;
}
#Makefile
a.out: main.o sort.o
gcc -o a.out main.o sort.o
sort.o: sort.c
gcc -o $@ -c $^
main.o : main.c
gcc -o $@ -c $^ clean:
rm -rf *.o a.out

#~/oucaijun/c/>make
make: Warning: File `Makefile' has modification time 43 s in the future
gcc -o main.o -c main.c
gcc -o sort.o -c sort.c
gcc -o a.out main.o sort.o
make: warning: Clock skew detected. Your build may be incomplete.
#~/oucaijun/c/>./a.out
start main
parry:1 4 5 23 17
parry:1 4 5 17 23

#~/oucaijun/c/>make clean
rm -rf *.o a.out

改Makefile:

#Makefile
a.out: main.o sort.o
gcc -o a.out main.o sort.o
*.o: *.c
gcc -o $@ -c $^ clean:
rm -rf *.o a.out

make
make: Warning: File `Makefile' has modification time 85 s in the future
cc -c -o main.o main.c
cc -c -o sort.o sort.c
gcc -o a.out main.o sort.o
make: warning: Clock skew detected. Your build may be incomplete.

改Makefile:

#Makefile
a.out: main.o sort.o
gcc -o a.out main.o sort.o
%.o: %.c
gcc -o $@ -c $^ clean:
rm -rf *.o a.out

make

make: Warning: File `Makefile' has modification time 71 s in the future
gcc -o main.o -c main.c
gcc -o sort.o -c sort.c
gcc -o a.out main.o sort.o
make: warning: Clock skew detected. Your build may be incomplete.

改Makefile

#Makefile
objs := main.o sort.o
a.out: $(objs)
gcc -o a.out $^
%.o: %.c
gcc -o $@ -c $^ clean:
rm -rf *.o a.out

  make结果仍同上.

objs := main.o sort.o
target := a.out
$(target): $(objs)
# gcc -o $@ $^ #ok
gcc -o $(target) $(objs) #ok
%.o: %.c
gcc -o $@ -c $^ clean:
rm -rf *.o a.out

  make结果仍同上.

Makefile以及链接库  http://blog.csdn.net/zkf11387/article/details/8039249

Makefile 里 -l和-L的区别  http://blog.csdn.net/dreamxu/article/details/6259206

gcc -o test test.c -L. -lcrexr64

-L.表示在当前目录(.)中查找函数库,-lcrexr64表示使用名为libcrexr64.a的函数库

-L/usr/lib -L/opt/app/oracle/product/10.2.0.1/lib 表示在/usr/lib 以及 /opt/app/oracle/product/10.2.0.1/lib中查找函数库

最新文章

  1. 设计模式C#合集--工厂方法模式
  2. JavaScript中绑定事件监听函数的通用方法addEvent() 和 事件绑定之bindEvent()与 unBindEvent()函数
  3. js/jquery 操作document对象
  4. (四面体)CCPC网络赛 HDU5839 Special Tetrahedron
  5. logstash+ElasticSearch+Kibana VS Splunk
  6. python_virtualenvwrapper安装与使用
  7. Hadoop2.x 体系结构和源码编译
  8. 安卓高级2 Volley框架的使用案例
  9. kafka 基础知识梳理及集群环境部署记录
  10. 【转】HashMap集合中key只能为引用数据类型,不能为基本类型
  11. C#_02.14_基础五_.NET类
  12. CSS深入理解之z-index
  13. 阵列卡raid H730写策略write-through和write-back配置说明
  14. 使用electron为贪吃蛇游戏创建全局快捷键
  15. JAVA按数字,字母排序,但不包括大小写和汉字排序
  16. Android-Java构造代码块&amp;构造方法隐式三行
  17. Erasure Coding(纠删码)深入分析
  18. 【记录】【持续更新】mybatis使用记录
  19. hadoop集群虚拟机配置
  20. RDLC设计

热门文章

  1. Python3 官方文档翻译 - 5 数据结构
  2. pxe网络安装操作系统 原理与详细过程
  3. SWIFT学习笔记01
  4. Codeforces 41D Pawn 简单dp
  5. Ubuntu设置为命令行登录
  6. arduino电子琴(2015-11-04)
  7. Xcode6中怎么添加空工程模板
  8. [置顶] Linux下文件和目录权限说明
  9. php开启虚拟域名功能
  10. DE1-SOC的sof文件无法下载解决办法