linux脚本: makefile以及链接库
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以及链接库的更多相关文章
- Linux中的共享链接库shared libraries
可执行文件的静态链接和动态链接静态链接会将需要的库函数在编译时一并包含, 所以体积会比较大. 使用ldd命令查看可执行文件链接的库 $ ldd /sbin/ldconfig not a dynamic ...
- linux动态链接库和静态链接库
Linux下静态链接库与动态链接库的区别 引言 通常情况下,对函数库的链接是放在编译时期(compile time)完成的.所有相关的对象文件 (object file)与牵涉到的函数库(librar ...
- Linux 下安装mysql 链接库
1.mysql 客户端 开发 链接库 1.1)CentOS yum install mysql-devel
- Linux 动态链接库包含静态链接库的方法
今天老司机们在讨论一个编译问题 A是一个静态库 C是一个动态库 B是运行程序,能不能将A打包到C 然后B只需要链接C 就可以了. 这个问题我以前在出来zlib库版本冲突的时候有点印象,所以写了个 ...
- linux网编 静态链接库
-L 指定动态库路径 -l 指定 以libXXXX.a命名的库文件
- windows/Linux动态加载链接库问题
windows: LoadLibraryA 指定的可执行模块映射到调用进程的地址空间并返回该 DLL 的句柄 HMODULE LoadLibraryA( LPCTSTR lpLibFileName// ...
- [转]Linux下的lds链接脚本详解
转载自:http://linux.chinaunix.net/techdoc/beginner/2009/08/12/1129972.shtml 一. 概论 每一个链接过程都由链接脚本(lin ...
- linux下动态链接库.so文件 静态链接库.a文件创建及使用
转摘网址为:http://www.cnblogs.com/fengyv/archive/2012/08/10/2631313.html Linux下文件的类型是不依赖于其后缀名的,但一般来讲: ...
- Linux下的lds链接脚本简介
转载:http://hubingforever.blog.163.com/blog/static/171040579201192472552886/ 一. 概论 每一个链接过程都由链接脚本(lin ...
随机推荐
- 在CTime类中重载<<和>>
程序代码: #include <iostream> using namespace std; class CTime//时间类 { private: unsigned short int ...
- 驱动: oops
linux驱动调试--段错误之oops信息分析 http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=29401328&id= ...
- 鸟哥私房菜--第1章 Linux 是什么
[只做搬运工,在搬运的时候窃看其中乐趣.] 历史渊源 Linus Torvalds(请记住这个名字)当年(1991)在写Linux的时候,初衷是针对386型机器的,当时只是一套裸露的操作系统并不包含任 ...
- BIOS和CMOS的联系与区别
BIOS为何物? BIOS就是(Basic Input/Output System,基本输入/输出系统的缩写)在电脑中起到了最基础的而又最重要的作用.是电脑中最基础的而又最重要的程序.把这一段程序放在 ...
- 一年四个P(Project)
盼望着,盼望着,提高班众多革命同胞的假期终于来了.伴随着校园之中越来越多的同学身影,暑假学习时的那份静谧一散而去,恍然间在提高班学习的第二个年头也已经过去了(~_~),而自己的大学生涯也就像秋后的蚂蚱 ...
- UVA 10763 Foreign Exchange 出国交换 pair+map
题意:给出很多对数字,看看每一对(a,b)能不能找到对应的(b,a). 放在贪心这其实有点像检索. 用stl做,map+pair. 记录每一对出现的次数,然后遍历看看对应的那一对出现的次数有没有和自己 ...
- linux路由表配置
一.原理说明 1.路由表(table)从0到255进行编号,每个编号可以对应一个别名,编号和别名的对应关系在linux下放在/etc/iproute2/rt_tables这个文件里,一般0编号的tab ...
- php - 小型微博系统
效果: 数据库: 项目结构: add.php : 添加微博. conn.php : 数据库配置文件. delete.php : 删除博客代码. disinfo.php : 显示微博详细信息. inde ...
- lvs、haproxy、nginx 负载均衡的比较分析
lvs和nginx都可以用作多机负载的方案,它们各有优缺,在生产环境中需要好好分析实际情况并加以利用. 首先提醒,做技术切不可人云亦云,我云即你云:同时也不可太趋向保守,过于相信旧有方式而等别人来帮你 ...
- Android 修改屏幕解锁方式
Android 修改屏幕解锁方式 问题 在手机第一次开机的时候,运行手机激活的APP 在激活APP允许过程中,当用户按电源键的时候,屏幕黑掉,进入锁屏状态 手机默认的锁屏是滑动解锁 用户这个时候再一次 ...