Issues with dynamically loading and "undefined symbol," errors
-
I'm writing a desktop app that is plugin driven. And I'm having a bit of an issue when it comes to loading up one of the plugins and getting an "undefined symbol," error at load time.
So I have my app structured like this:
lib/
-> Common library for everything, includes custom widgets and utility functionsapp
/ -> Contains the bare "runner" app that setups a window context and load the pluginsworkspaces/
-> Loadable plugins that define workspaces.
The binary application generated from
app/
and the plugins fromworkspaces/
both dynamically link against the generated commonly library. I have everything sent to thebuild/
directory upon successful compilation. So after everything builds, I get a structure like this:build/foo.bin
build/libFoo.so
build/workspaces/libEditWorkspace.so
The user is supposed to run
foo.bin
from thebuild/
directory. The app loads fine, then it scans thebuild/workspaces/
directory for possible workspaces. While it is able to successfully load theEditWorkspace
, I'm getting that undefined reference after the loading happens.I have a custom widget called
TextToggleButton
which is a sublcass ofQPushButton
. I've exported it usingextern "C"
andQ_DECL_EXPORT
, but when theEditWorkspaces
tries to instantiate aTextToggleButton
, it's giving off an error like this:./foo.bin: symbol lookup error: /home/me/Projects/foo/build/workspaces/libEditWorkspace.so: undefined symbol: _ZN17TextToggleButtonC1EP7QWidget
I'm really puzzled what the issue is here. I have everything linked properly at compile time. What could be wrong here?
-
@define-private-public said in Issues with dynamically loading and "undefined symbol," errors:
I have a custom widget called TextToggleButton which is a sublcass of QPushButton. I've exported it using extern "C" and Q_DECL_EXPORT, but when the EditWorkspaces tries to instantiate a TextToggleButton, it's giving off an error like this:
Qt has a plugin system in place so there's no real need to reinvent the wheel. But for the sake of argument, please provide a code snippet for how you derive from the push button, and how you do the export, also how you're trying to load that library.
-
I figured out my problem... I forgot to include the widget in the
.lib.pro
file...