View Full Version : Dynamic lookup problem

30th May 2006, 13:48

My application uses QPlugins. These plugins are a glue between my application objetcs and several libraries. Anyway, in a plugin project file I just specify :

CONFIG += plugin release
INCLUDEPATH += /Path/To/The/Application/Headers
HEADERS += Plugin.h
SOURCES += Plugin.cpp

So of course, running nm on the library tells that several symbols are undefined. No problem, they will be found at runtime since the application defines them. It works perfectly well on linux when the plugin config is not set.

To make this compile on MacOsX you need to add in your project file :

QMAKE_LFLAGS += -undefined dynamic_lookup

So the plugin works on MacOSX but on linux I have undefined symbols at runtime : symbol lookup error. These problems only occurs with function defined in a source file within a namespace. Declaring them in the header solves the problem but this is not a solution.

By default objects are compiled with -fPIC and the plugin is linked with -shared so that it should work but it doesn't :confused:

Does anybody have a solution to make my plugins work on linux ?

30th May 2006, 13:53

30th May 2006, 14:49
To add in the application project file instead of the plugin project file as I tried before.

Thank you.

30th May 2006, 15:19
To add in the application project file instead of the plugin project file as I tried before.

Yes, of course :) I forgot to mention that. It is the main application which has to export the symbols so that plugins can resolve them.

Unfortunately, solutions like those mentioned in this thread are not available on Windows.

Another way to achieve the same (a way which should work on all platforms) is to export all the functionality the plugins use to an external library and link (dynamically) both plugins and the main application with it. This way all symbols will be resolved from the shared object without any special tricks.