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 ...
随机推荐
- MFC不使用对话框资源模版创建对话框
在MFC程序中使用对话框时首先在资源模版里创建对话框资源,然后DoModal()或者CReate显示出模式对话框或者非模式对话框,这样创建出的对话框移植性差,从一个工程移动到另一个工程比较麻烦. 在M ...
- java多线程制作计时器
基本思路: 在类中创建thread 供按钮监听器调用. 界面设计:
- 如何提高banner设计含量--网上的一篇文章--感悟
"修改": 本质上是改什么?改大小?图片?文字?颜色? 老板说:修改本质上是提高“设计含量”.检测一个作品设计含量的高低,可以将作品中每一个设计元素进行分析,看它的“属性”与“操作 ...
- C++_01_入门
一.类的定义 Person.h类声明 Person.cpp类实现 main.cpp主函数 二.命名空间的使用 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv ...
- android Graphics(二):路径及文字
前言:今天项目进入攻关期,他们改Bug要改疯掉了,主管为了激励大家,给大家发了一封邮件,讲到他对项目和学习的理解,一个很好的图形模型,分享给大家,如图在下面给出:(不便给出原文,我仅做转述)无论是学习 ...
- junit4笔记
这两天在复习hibernate,看的小峰的视频,觉得很不错. 现在把里面的junit4的一些使用方法记下来.方便以后的差用.代码如下. package com.java1234.service; im ...
- USACO Party Lamps 【Binary code solvution】【规律】
写这道题目的时候遇到了一个令人诧异的问题,就是平台上跑来的结果和我本机跑起来的结果不一样. 后来Debug了之后才发现是我数组开小了,只开到100 的数组竟然都去访问他170位的地址肯定要跪成翔啊.. ...
- 基于visual Studio2013解决算法导论之018栈实现(基于链表)
题目 用链表实现栈 解决代码及点评 #include <stdio.h> #include <stdlib.h> #include <time.h> #in ...
- 使用GridView来获取xml文件数据
在任何一个系统中,数据的读取和编辑都是至关重要的.无论你是CS还是BS,都需要对数据进行操作.其实 我们可以发现,很多软件和系统最终都是对于数据库中数据的处理.之前在CS的学习过程中我们接触到了很多 ...
- [置顶] Android自定义控件大全
1,自定义Edittext, TextView,带底线的Edittext, TextView 2.自定义圆形ImageView,圆角ImageView 3,下拉刷新LinearLayout 4,多点触 ...