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中查找函数库

linux脚本: makefile以及链接库的更多相关文章

  1. Linux中的共享链接库shared libraries

    可执行文件的静态链接和动态链接静态链接会将需要的库函数在编译时一并包含, 所以体积会比较大. 使用ldd命令查看可执行文件链接的库 $ ldd /sbin/ldconfig not a dynamic ...

  2. linux动态链接库和静态链接库

    Linux下静态链接库与动态链接库的区别 引言 通常情况下,对函数库的链接是放在编译时期(compile time)完成的.所有相关的对象文件 (object file)与牵涉到的函数库(librar ...

  3. Linux 下安装mysql 链接库

    1.mysql 客户端 开发 链接库 1.1)CentOS yum install mysql-devel

  4. Linux 动态链接库包含静态链接库的方法

    今天老司机们在讨论一个编译问题  A是一个静态库  C是一个动态库  B是运行程序,能不能将A打包到C 然后B只需要链接C 就可以了. 这个问题我以前在出来zlib库版本冲突的时候有点印象,所以写了个 ...

  5. linux网编 静态链接库

    -L 指定动态库路径 -l 指定 以libXXXX.a命名的库文件

  6. windows/Linux动态加载链接库问题

    windows: LoadLibraryA 指定的可执行模块映射到调用进程的地址空间并返回该 DLL 的句柄 HMODULE LoadLibraryA( LPCTSTR lpLibFileName// ...

  7. [转]Linux下的lds链接脚本详解

    转载自:http://linux.chinaunix.net/techdoc/beginner/2009/08/12/1129972.shtml     一. 概论 每一个链接过程都由链接脚本(lin ...

  8. linux下动态链接库.so文件 静态链接库.a文件创建及使用

    转摘网址为:http://www.cnblogs.com/fengyv/archive/2012/08/10/2631313.html Linux下文件的类型是不依赖于其后缀名的,但一般来讲:    ...

  9. Linux下的lds链接脚本简介

    转载:http://hubingforever.blog.163.com/blog/static/171040579201192472552886/   一. 概论 每一个链接过程都由链接脚本(lin ...

随机推荐

  1. Sicily-1024

    一. 题意: 有n个节点,n-1条边,并且任意两个节点都连通.模拟一下,实际上是一棵树的便利,求从特定根节点出发最长路径的值.这里用了广搜. 二. 每个节点只有两条邻接边,每个节点用一个vector来 ...

  2. Android平台一些流行的使用3D技术开发的锁屏

    题外话:从2007年android系统的发布开始,到2008年的第一款手机问世,再到现在击败塞班,wm,黑霉,然后遍地开花,2013年,智能机出货超过了功能机,android功不可没.一路走来,虽然a ...

  3. 二分法查找的C语言实现:

    #include <stdio.h> int binSearch(int, int, int); main() { int i, n = 10, x = 7; //这里假设把数组a[]定义 ...

  4. android动画效果演示

    第一种:TranslateAnimation  动画效果演示: public void move(View view) { // 传统动画效果 TranslateAnimation animation ...

  5. MVC是一种用于表示层设计的复合设计模式

    它们之间的交互有以下几种:       1.当用户在视图上做任何需要调用模型的操作时,它的请求将被控制器截获.       2.控制器按照自身指定的策略,将用户行为翻译成模型操作,调用模型相应逻辑实现 ...

  6. 不老的新丁 Python何以让人着迷

    Python是一门美丽的语言.它简单易学,跨平台,而且运转良好.达成了许多Java一直求索的技术目标.一言以蔽之就是:其他的语言是与时代同 步,而Python则是未雨绸缪,而且计划得颇为出色.当然,这 ...

  7. struts2_4_为Action属性注入值

    Struts2为Action中的属性提供了依赖注入功能,在struts2的配置文件里,能够为Action中的属性注入值,属性必须提供setter方法. 1)employeeAction类: publi ...

  8. CMake使用之一

    概述 CMake是一个比make更高级的编译配置工具,它可以根据不同平台.不同的编译器,生成相应的Makefile或者vcproj项目. 通过编写CMakeLists.txt,可以控制生成的Makef ...

  9. Linux命令: chown

    touch auth.log root@ubuntu:/work# ls -l auth.log -rw-r--r-- 1 root root 0 Feb 18 19:27 auth.log chow ...

  10. BZOJ 2429: [HAOI2006]聪明的猴子( MST )

    水题, 求MST即可. -------------------------------------------------------------------------------- #includ ...