导出和使用外部符号
来源:互联网 发布:如何做网络写手 编辑:程序博客网 时间:2024/06/16 05:42
模块A:定义并导出了两个函数(红色标注)
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
static char *who= "who";
static int time= 1;
module_param(time, int, S_IRUGO);
module_param(who, charp, S_IRUGO);
static int hello_init(void)
{
return 0;
}
static int hello_exit(void)
{
return 0;
}
int add_intergar(int a,int b)//define add
{
return (a+b);
}
int dec_intergar(int a,int b)//define dec
{
return (a-b);
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("Dual BSD/GPL");
EXPORT_SYMBOL(who);
EXPORT_SYMBOL(time);
EXPORT_SYMBOL(add_intergar);//导出
EXPORT_SYMBOL(dec_intergar);//导出
模块b:使用模块a中导出的符号(红色部分)
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
extern int add_intergar(int a,int b);//外部声明
extern int dec_intergar(int a,int b);//外部声明
static int hello_init(void)
{
int i=0;
printk(KERN_EMERG"add symbol::::%d\n",add_intergar(2,5));//使用!
printk(KERN_EMERG"dec symbol::::%d\n",dec_intergar(2,5));
return 0;
}
static int hello_exit(void)
{
printk(KERN_EMERG"GOOBYE,WORLD\n");
return 0;
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("Dual BSD/GPL");
编译模块b的时候将编译模块a过程产生的Module.symvers文件cp到当前目录(看编译器配置,非必要),然后make,记得插入模块的顺序。
插入b的结果:
[root@localhost symbol_export]#
Message from syslogd@ at Sat Nov 12 22:43:14 2011 ...
localhost kernel: add symbol::::7
Message from syslogd@ at Sat Nov 12 22:43:14 2011 ...
localhost kernel: dec symbol::::-3
- 导出和使用外部符号
- 内核模块导出符号使用
- dll导出(无法解析的外部符号 "__declspec(dllimport))
- coco2dx 3.0使用sqlite3和network时出现无法解析的外部符号的解决方案
- 使用monogodbexport导出query中符号“$”转义
- 查看静态库(.lib)和动态库(.dll)的导出函数的信息 error LNK2001: 无法解析的外部符号 _Delete
- 模块间(dll, exe)使用导出变量、静态变量和外部变量的试验与结论
- 使用boost时,编译没通过--无法解析外部符号
- 使用dinput 出现error LNK2001: 无法解析的外部符号
- 使用C调用lua 无法解释的外部符号
- error LNK2001: 无法解析的外部符号 CLSID_ImagingFactory 和 IID_IImagingFactory
- 遭遇无法解析的外部符号encodepointer和decodepointer
- 函数导出方式不对,导致的“error link2019 无法解析的外部符号 ”
- 调用导出dll中的类成员函数 - error LNK2019: 无法解析的外部符号
- 解决外部符号错误
- 找不到外部符号
- 无法解析外部符号
- 无法解析的外部符号和该符号在函数_wmain 中被引用的解决方法
- Qt的Model/View (二)
- JNI学习(1)
- Jar Hell 问题解决方案
- Qt 对象数据的声明和使用
- systemverilog interface
- 导出和使用外部符号
- 使用qt命令来编译的基本步骤
- 单例模式【Design Pattern Singleton 】
- 手机QQ的安卓版,自己写的!附源码!
- 基于skyline的城市三维建模研究
- 《无懈可击的web设计II》读书笔记
- 继续聊WPF——BulletDecorator控件
- 解密七种html网页加密解密法
- 留学生奇谈:贫穷落后的美国 一个留学生的感叹!