C pluginsystem: symbol lookup error

雨燕双飞 提交于 2019-12-11 16:53:55

问题


I am writing a plugin system which is separated other 3 modules:

  1. plugin_system.c - the core of the system
  2. list.c - contains a linked list implementation for plugins' storage
  3. plugin_interface.h - contains the declaration needed by plugins, has no source file associated with

plugin_interface.h only contains only of types and the function:

 extern int plugin_register(PluginManager *plug_manager, const char *name, Plugin *plug);

which is defined in plugin_system.c

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.

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

A plugin is compiled with gcc -fPIC -c -o plugname.o plugname.c plug_system.o followed by gcc -o plugname.so 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

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...


回答1:


I just forgot to link the plugin with list.o which is used by the plugin_system.o...



来源:https://stackoverflow.com/questions/36797376/c-pluginsystem-symbol-lookup-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!