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 functions
    • app/ -> Contains the bare "runner" app that setups a window context and load the plugins
    • workspaces/ -> Loadable plugins that define workspaces.

    The binary application generated from app/ and the plugins from workspaces/ both dynamically link against the generated commonly library. I have everything sent to the build/ 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 the build/ directory. The app loads fine, then it scans the build/workspaces/ directory for possible workspaces. While it is able to successfully load the EditWorkspace, I'm getting that undefined reference after the loading happens.

    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:

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


  • Qt Champions 2016

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



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.