Results 1 to 4 of 4

Thread: Dynamic lookup problem

  1. #1
    Join Date
    Apr 2006
    Posts
    29
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Post Dynamic lookup problem

    Hi,

    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 :

    Qt Code:
    1. TEMPLATE = lib
    2. CONFIG += plugin release
    3. ...
    4. INCLUDEPATH += /Path/To/The/Application/Headers
    5. HEADERS += Plugin.h
    6. SOURCES += Plugin.cpp
    To copy to clipboard, switch view to plain text mode 

    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 :

    Qt Code:
    1. QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3
    2. QMAKE_LFLAGS += -undefined dynamic_lookup
    To copy to clipboard, switch view to plain text mode 

    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

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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Dynamic lookup problem

    QMAKE_LFLAGS+=-rdynamic

  3. #3
    Join Date
    Apr 2006
    Posts
    29
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Post [solved] Dynamic lookup problem

    To add in the application project file instead of the plugin project file as I tried before.

    Thank you.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [solved] Dynamic lookup problem

    Quote Originally Posted by jwintz
    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.

Similar Threads

  1. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  2. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  3. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. Runtime dynamic linking + Qt4 problem
    By _Ramirez_ in forum Qt Programming
    Replies: 5
    Last Post: 11th February 2006, 14:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.