编译 库链接实例(动态库 隐式显式)
来源:互联网 发布:传奇数据库 编辑:程序博客网 时间:2024/06/14 08:42
代码结构:
main.c
#include <stdio.h>#include "help.h"int main(){ printf("%d\n", test(250)); return 0;}main1.c
#include <stdio.h>#include <dlfcn.h>int main(){int ret = 1;void *pHandle;int (*pFunc)(int );pHandle = dlopen("./cj.so", RTLD_NOW);if (!pHandle){printf("Cann't find cj.so\n");return 1;}pFunc = (int (*) (int )) dlsym(pHandle, "test");if(pFunc){printf("result is %d\n",pFunc(250));}else{printf("Cann't find func test\n");}dlclose(pHandle);return 0;}help.c
#include <stdio.h>#include "help.h"int test(int num){return num*2;}
help1.c
#include<stdio.h>#include "help.h"int test(int a){return a*3;}help.h
#ifndef HELP_H#define HELP_Hint test(int );#endif
使用 -I 指定main.c中使用到的头文件的路径(若和main.c在同一目录,可以不使用)
静态库的使用
-L 指定静态库路径
动态库 的 隐式链接:记得带路径链接动态库
无需再次链接,动态更换库
动态库的显示链接:
动态库流程
各方式对比:
阅读全文
0 0
- 编译 库链接实例(动态库 隐式显式)
- 编译动态链接库
- ubuntu下动态链接库的编译和使用实例
- ubuntu下动态链接库的编译和使用实例
- Linux 动态链接库的编译和使用实例
- ubuntu下动态链接库的编译和使用实例
- 实例动态链接库编程
- 实例动态链接库编程
- 静态编译,动态编译,静态链接库,动态链接库
- 动态链接库的编译链接
- 命令行下编译链接动态链接库
- linux 编译,链接,动态链接库
- 动态链接库的编译链接
- 编译链接动态链接库生成调用
- 如何编译动态链接库
- gcc编译动态链接库
- gcc 编译动态链接库
- linux 动态链接库编译
- java 判断字符串是否包含汉字的方法
- 数据结构_线性表_链表实现
- 记一次跨域问题的解决方案
- 浮动之QQ会员页面导航
- 【Spring】Spring+Struts2+Hibernate3整合(十七)
- 编译 库链接实例(动态库 隐式显式)
- 解决xcode打开时假死的问题
- NEUQ oj 1036 题解
- RadioGroup设置点击text的基本布局样本
- 使用tensorflow:LSTM神经网络预测股票(三)
- 感知机模型(原始形式和对偶形式)
- jQuery动态给form表单赋值
- GIT教程 — 浅析分支管理(一)
- 多线程 之 setDaemon