一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

centos系统make install 安装程序包案例

时间:2016-10-30 编辑:简简单单 来源:一聚教程网


准备写好的c文件

1、ws.h 【头文件,声明函数名,未实现】
2、wso.c【包含函数体,实现函数,需要编译成动态链接库】
3、ws.h 【主程序执行文件】

新建makefile文件

toucu makefile 建立makefile文件
vi makefile    编辑makefile,
在makefile编写make命令可执行的code

newws:ws.c libme.so
        gcc -L ./ -l me ws.c -o newws
libme.so:ws.c
        gcc -shared wso.c -o libme.so
install:
        cp ./libme.so /lib64
        ldconfig

命令解析:  1、 makefile格式 最终生成的文件 newws 依赖于 shenyi.c libme.so  2、gcc生成编译文件命令 -L ./ 当前目录 -l mewso.c 生成最终newws  3、 libme.so 依赖于 ws.c  4、生成编译文件.so的命令(ws.c变成成libme.so)  5、make install 安装

  5.1、将编译文件拷入核心库
  5.2、更新缓存

热门栏目