Çpluginsystem:符号查找错误 [英] C pluginsystem: symbol lookup error
问题描述
我写这被分离等3个模块插件系统:
I am writing a plugin system which is separated other 3 modules:
- 的 plugin_system.c 的 - 该系统的核心
- 的 list.c 的 - 包含了插件的存储链表实现
- 的 plugin_interface.h 的 - 包含由插件所需要的声明,已与相关联的源文件
- plugin_system.c - the core of the system
- list.c - contains a linked list implementation for plugins' storage
- plugin_interface.h - contains the declaration needed by plugins, has no source file associated with
的 plugin_interface.h 的只包含唯一的类型和功能:
plugin_interface.h only contains only of types and the function:
extern int plugin_register(PluginManager *plug_manager, const char *name, Plugin *plug);
这是在定义的 plugin_system.c 的
当加载插件,该插件系统找一个函数, init_plugname()
并调用它,该函数必须调用 plugin_register
来注册插件。
When loading a plugin, the plugin system look for a funcion init_plugname()
and call it, that function must call plugin_register
to register the plugin.
程序编译复杂递归Makefile中(不是最好的想法),但我尽量做到的是:
The program is compiled with complex recursive Makefiles (not the best idea), but what I try to achieve is:
我编译在主程序文件夹中的插件系统对象,它然后与主程序链接。从制作
执行
I compile the plugin system object in the main program folder, it is then linked with the main program. From make
execution:
gcc -Wall -O2 -std=gnu99 -D DEBUG -g -fPIC -c -o /home/kowa/code/reseaux/projet/ringo/c/bin/list.o list.c
gcc -Wall -O2 -std=gnu99 -D DEBUG -g -fPIC -c -o /home/kowa/code/reseaux/projet/ringo/c/bin/plugin_system.o plugin_system.c
一个插件编译的gcc -fPIC -c -o plugname.o plugname.c plug_system.o
然后按 GCC -o plugname。所以plugname.o plug_system.o -shared
我尝试加载插件在我的主程序和得到这个错误:
I try to load the plugin in my main program and get this error:
symbol lookup error: ./plugins/zyva.so: undefined symbol: exists
存在
是由 plugin_system 的模块存储插件,在 plugin_register 使用列表模块中的功能code>功能mentionned aboved调用它。
exists
is a function in the list module used by the plugin_system module to store plugins, the plugin_register
function mentionned aboved calls it.
我从来没有做过那样的系统之前,我不共享库的专家,我想这个问题是我怎么编译整个项目,我可能会错过一些联动...
I've never done that kind of system before and I'm not an expert in shared library, I guess the problem is from how I compile the whole project, I may miss some linkage...
推荐答案
我只是忘了插件与链接的 list.o 的这所使用的的 plugin_system.o 的...
I just forgot to link the plugin with list.o which is used by the plugin_system.o...
这篇关于Çpluginsystem:符号查找错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!