Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issues with dynamically loading and "undefined symbol," errors

Issues with dynamically loading and "undefined symbol," errors

Scheduled Pinned Locked Moved Solved General and Desktop
pluginqlibrarydlldllexportdllimport
3 Posts 2 Posters 3.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    define-private-public
    wrote on 31 Oct 2017, 02:37 last edited by
    #1

    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?

    K 1 Reply Last reply 31 Oct 2017, 12:46
    0
    • D define-private-public
      31 Oct 2017, 02:37

      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?

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 31 Oct 2017, 12:46 last edited by
      #2

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

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      1
      • D Offline
        D Offline
        define-private-public
        wrote on 31 Oct 2017, 22:38 last edited by
        #3

        I figured out my problem... I forgot to include the widget in the .lib.pro file...

        1 Reply Last reply
        0

        3/3

        31 Oct 2017, 22:38

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved