lib库的生成与使用
来源:互联网 发布:战略思维 知乎 编辑:程序博客网 时间:2024/05/22 15:21
例:
test.h:
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
int Max(int a, int b);
int display();
Max.c:
#include "test.h"
int Max(int a, int b)
{
return a > b ? a: b ;
}
display.c :
#include "test.h"
void display()
{
printf("Hello world\n");
}
test.c :
#include "test.h"
int main()
{
int ret = 0;
ret = Max(1, 10);
printf("Max is %d\n", ret);
display();
return 0;
}
1,把didplay.c, Max.c加入同时并生成libdis.so动态库
gcc display.c Max.c -fPIC -shared -o libdis.so
2,把libdis.so复制到系统/usr/lib文件夹中
cp libdis.so /usr/lib
3,把test.c与libdis.so绑定关系
gcc test.c -L. -ldis -o test
4,测试test是否绑定成功
ldd test
显示出地址即OK
5,运行test
./test
显示出执行函数的结果
- lib库的生成与使用
- DLL与LIB库文件的生成和使用
- DLL与LIB库文件的生成和使用---C++
- DLL与LIB库文件的生成和使用---C++
- DLL与LIB库文件的生成和使用---C++
- DLL与LIB库文件的生成和使用---C++
- vs2013中静态库lib文件的生成与使用
- DLL与LIB库文件的生成和使用---C++
- DLL与LIB库文件的生成和使用---C++
- keil中lib的生成与使用
- c++中使用外部库exe,.dll与.lib文件的生成与使用的详解
- c++中.dll与.lib文件的生成与使用
- 【Cortex-M0】19.2 LIB的生成与使用
- VS2013下 .lib和.dll的生成与使用
- VS2013下静态链接库(lib)和动态链接库(dll)的生成与使用
- Keil C 里面Lib库文件的生成与调用
- Keil中LIB库的作用、生成与调用
- 静态连接库(lib)的生成与调用
- css语法(转自“清清月儿”)
- 2011 江苏考生文化课304 选修CC 在江苏志愿参考
- CSS定位 (转自”清清月儿“)
- Android提高十七篇之多级树形菜单的实现
- zoj 1542 【Kruskal算法】
- lib库的生成与使用
- Linux iptables 防火墙状态
- DW中CSS属性详解 .(转自”清清月儿“)
- dev gridview 循环所有行、列 取值
- javascript kb
- Windows下的Memcache安装
- magent操作
- repo upload时报错“Cannot guess Gerrit version” 解决方案
- 基于命令行模式开发ANDROID应用