Linux的Terminal中如何生成动态库以及如何使用动态库
来源:互联网 发布:恩威宝app软件下载 编辑:程序博客网 时间:2024/05/29 03:53
dll.c:
#include<stdio.h>void dll_init(){printf("dll_init ...\n");}
dll.h:
#ifndef __DLL_H#define __DLL_Hvoid dll_init();#endif
makefile:
.PHONY:cleanhello:main.o gcc -o hello main.o -L./ -ldllmain.o:main.c gcc -o $@ -c -fPIC $^clean: rm -f main.o hello
指令执行:
root@ubuntu:~/lesson/chap2/2-6/2-6-2/test# makegcc -o hello main.o -L./ -ldllroot@ubuntu:~/lesson/chap2/2-6/2-6-2/test# lsdll.c dll.h hello libdll.so main.c main.o makefileroot@ubuntu:~/lesson/chap2/2-6/2-6-2/test# ./hello./hello: error while loading shared libraries: libdll.so: cannot open shared object file: No such file or directoryroot@ubuntu:~/lesson/chap2/2-6/2-6-2/test# cp libdll.so /usr/lib #把动态库存在库文件夹里面,才能运行./helloroot@ubuntu:~/lesson/chap2/2-6/2-6-2/test# ./hellohello wordld!dll_init ...root@ubuntu:~/lesson/chap2/2-6/2-6-2/test#
注意: .代表当前文件夹.
阅读全文
0 0
- Linux的Terminal中如何生成动态库以及如何使用动态库
- Linux的Terminal中如何生成静态库以及如何使用静态库
- C++文件如何在linux下生成动态库So,以及如何使用这个动态库
- C++文件如何在linux下生成动态库So,以及如何使用这个动态库
- C++文件如何在linux下生成动态库So,以及如何使用这个动态库
- Linux 如何使用gcc生成静态库和动态库
- linux如何使用gcc生成静态库和动态库
- linux中静态库和动态库的生成以及使用
- java中如何使用asm动态的生成或修改一个class文件以及asm的架构思想
- linux 动态库的生成与使用
- linux 动态库的生成和使用
- linux动态库的生成与使用
- 如何使用gcc检查动态库中符号的完整性
- 如何在C++中使用共享库的动态加载
- 如何在Java中构造多维动态数组以及多维动态数组的使用
- linux如何动态加载动态库
- Linux下如何生成静态库和动态库
- Linux 如何生成静态库和动态库
- Unity3d VR与Android项目关联
- 适配器模式应用实战课程9月5日开课了_上课了在线平台
- Java int 最大值溢出
- Linux 用户管理
- 关于概率与期望
- Linux的Terminal中如何生成动态库以及如何使用动态库
- idea导入spring源码提示jar包找不到错误修改方法
- redis配置
- 1167: 逆转数(指针专题)
- putty提示Network error:Software caused connection abort
- 表1爬虫
- 使用JWT和Spring Security保护REST API
- 学习算法之冒泡排序
- 深入解析:分布式系统的事务处理经典问题及模型