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. [SOLVED] Qt Creator Widget plugin: strange linker error
Qt 6.11 is out! See what's new in the release blog

[SOLVED] Qt Creator Widget plugin: strange linker error

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 7.5k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    soroush
    wrote on last edited by
    #3

    This is error I get:
    @
    ./ui_mainwindow.h:132: undefined reference to `DateQuery::DateQuery(QWidget*)'
    collect2: ld returned 1 exit status
    @
    And implementation of constructor:
    @
    // datequery.cpp:
    DateQuery::DateQuery(QWidget *parent) :
    QWidget(parent)
    {
    setupUi(this);
    }
    @

    1 Reply Last reply
    0
    • S Offline
      S Offline
      soroush
      wrote on last edited by
      #4

      [quote author="mkuettler" date="1337357139"]
      Do you link to the correct files?[/quote]

      Yes I think I'm linking corerctly. I do this:

      make project

      Close Qt Creator

      sudo make uninstall && sudo make install

      Copy header files to /usr/include/agt

      And in .pro file of application:
      @
      LIBS += -lagtplugin
      INCLUDEPATH += /usr/include/agt
      @

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mkuettler
        wrote on last edited by
        #5

        Are you sure datequery.cpp is included in the linking process?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mkuettler
          wrote on last edited by
          #6

          Sorry, I didn't see your last post when I wrote mine. From what you write I can't tell if everything is correct, but it looks good to me. Still, the error message means that the linker cannot find the implementation of the constructor, and I assume the file is not visible to the linker. I cannot think of an other reason.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dbzhang800
            wrote on last edited by
            #7

            [quote author="soroush" date="1337357660"]
            And in .pro file of application:
            @
            LIBS += -lagtplugin
            INCLUDEPATH += /usr/include/agt
            @[/quote]

            I do not understand one thing: why do you need link to the "agtplugin"? It's really a plugin like your said in the thread title?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              soroush
              wrote on last edited by
              #8

              [quote author="1+1=2" date="1337358491"]
              [quote author="soroush" date="1337357660"]
              And in .pro file of application:
              @
              LIBS += -lagtplugin
              INCLUDEPATH += /usr/include/agt
              @[/quote]

              I do not understand one thing: why do you need link to the "agtplugin"? It's really a plugin like your said in the thread title?[/quote]

              Its a widget library. I removed LIBS += -lagtplugin and got 8 linker errors (for all 8 widgets I put on my main window)

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dbzhang800
                wrote on last edited by
                #9

                Oh, I see, what you really mean is a normal shared library instead of a plugin.

                If I am right. what you are doing is:

                • Changed source code of a library(By adding a new class)
                • Rebuild the library
                • Install it (Wait... In which place you install it ?)
                • Copy header files (Doesn't this done in last step?)
                • Using your library by LIBS and INCLUDEPATH (Wait... are your sure LIBS += -lagtplugin linked to your new build library?)

                By the way, whether the QtCreator generated code inherit from Ui::<widget_name> or not depends on youself. Please go to "Tools/Options/Designer/..."

                Debao

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  soroush
                  wrote on last edited by
                  #10

                  [quote author="1+1=2" date="1337366955"]
                  By the way, whether the QtCreator generated code inherit from Ui::<widget_name> or not depends on youself. Please go to "Tools/Options/Designer/..."
                  [/quote]

                  Oh! Thank you! I didn't know that :)

                  bq. Install it (Wait… In which place you install it ?)

                  Makefile installs it on /usr/lib/x86_64-linux-gnu/qt4/plugins/designer/libagtplugin.so . After sudo make install I can see widgets in Qt Creator.

                  bq. Copy header files (Doesn’t this done in last step?)

                  I think it's not done by build system. I have to copy headers in /usr/include or somewhere else and let other projects know about their location. Am I doing it wrong?

                  bq. are your sure LIBS += -lagtplugin linked to your new build library?

                  Removing library by sudo make uninstall. Output is like:
                  rm -f "/usr/lib/x86_64-linux-gnu/qt4/plugins/designer/libagtplugin.so"
                  So I can say, yes I'm sure.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dbzhang800
                    wrote on last edited by
                    #11

                    ;-( I am really confused by what you are doing now.

                    bq. Makefile installs it on /usr/lib/x86_64-linux-gnu/qt4/plugins/designer/libagtplugin.so . After sudo make install I can see widgets in Qt Creator.

                    Ok, you really build a plugin for designer. but this plugin doesn't intent to be used by application.

                    Though you can use it as a normal shared library in your application if you export symbols properly, but it is not encouraged.

                    Normally, you need to build a shared library, which can be used by your application, or optionally by your designer plugin.

                    bq. I think it’s not done by build system. I have to copy headers in /usr/include or somewhere else and let other projects know about their location. Am I doing it wrong?

                    Which files need to be installed, and where to install them , all controlled by yourself. look your xxx.pro files carefully if it is not written by yourself manually.

                    bq. Removing library by sudo make uninstall. Output is like:
                    rm -f “/usr/lib/x86_64-linux-gnu/qt4/plugins/designer/libagtplugin.so”
                    So I can say, yes I’m sure.

                    No, You still don't give evidence that this is the library to be linked by your linker.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      soroush
                      wrote on last edited by
                      #12

                      [quote author="1+1=2" date="1337370924"]
                      No, You still don't give evidence that this is the library to be linked by your linker.[/quote]

                      This is a part of output of ldd ./cards-report (the application that uses widget library)
                      @
                      ....
                      /usr/lib/x86_64-linux-gnu/qt4/plugins/designer/libagtplugin.so (0x00007f0b17c0d000)
                      ....
                      @

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        soroush
                        wrote on last edited by
                        #13

                        Ahhh... Finally!
                        Projects, have to be rebuilt after any changes applied to any of libraries they linked against. Though I thought this is only true for statically linked libraries...
                        I learned this today :)

                        1 Reply Last reply
                        0

                        • Login

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