linux .so 文件中函数名称和程序中的函数名称相同
2014-02-21 17:07
337 查看
~/so_test $ cat testlib.h #ifndef __LIB_TEST_H__ #define __LIB_TEST_H__ void libxx(); #endif
~/so_test $ cat testlib.c #include <stdio.h> #include <stdlib.h> void libxx() { printf("come from libxx.so\n"); }
~/so_test $ cat main.c #include "testlib.h" #include <stdlib.h> #include <stdio.h> #if 0 void libxx() { printf("come from prg!\n"); } #endif int main(int argc, char *argv[]) { libxx(); return 0; }
~/so_test $ gcc -fpic -shared -o libtest.so testlib.c
~/so_test $ gcc -l/home/admin/so_test -o main.o -c main.c
~/so_test $ gcc -o main -L/home/admin/so_test main.o -ltest
如果程序中有 libxx 这个函数 运行的时候调用的是程序中的, 如果 程序中没有这个函数那么就调用库里面的
相关文章推荐
- Linux虚机下添加新硬盘后挂载及分区方法
- Linux任务调度(一)—at
- LINUX 比较参数(test)
- linux VPS之间网站数据的备份与恢复(网站迁移教程)
- linux下JBOSS安装
- Linux下的I/O
- 在centos中添加开机自启动服务
- linux 带宽实时查看iftop
- Linux命令之:rm
- 使用代码验证linux子进程与父进程的关系
- 16.(25)linux备份策略
- linux0.11源代码电梯算法解析
- WEB固件升级
- LINUX DNS检测
- 8.程序管理与SELinux初探
- linux文件描述符和重定向
- php oauth 模块在linux下安装
- 如何编译Linux的内核
- linux 常用命令
- 5.linux帐号管理与权限设定