Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt5 static build has multiple defined symbols on link
Forum Updated to NodeBB v4.3 + New Features

Qt5 static build has multiple defined symbols on link

Scheduled Pinned Locked Moved Installation and Deployment
10 Posts 3 Posters 6.0k 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.
  • R Offline
    R Offline
    radman0x
    wrote on last edited by
    #1

    Hi,

    I've been trying to build Qt5.0.2 for a little while now and am finally down to the last error. When linking in all the static libraries I get a multiple defined symbols error between Qt5Gui and Qt5OpenGL (see attached link output). I have tried swapping the order og Qt5Gui and Qt5OpenGL and (as expected) the error persists. I have looked at the source code and there are definitely 2 different files that define the same class being used by the two different libraries. I'm at the point where I can't solve this without understanding the specifics of the qt package and so I'm wondering if anyone here can help me out?

    Files:
    ./qtbase/src/gui/opengl/qopenglpaintengine_p.h
    ./qtbase/src/gui/opengl/qopenglpaintengine.cpp

    ./qtbase/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
    ./qtbase/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h

    Configure:
    ./configure -static -opensource -confirm-license -nomake tests

    Make:
    make module-qtbase
    make module-qtdeclarative

    Link: (relevant parts shown)
    -lQt5QuickTest -lQt5QmlDevTools -lQt5QuickParticles -lQt5Quick -lQt5Qml -lQt5V8 -lQt5Network -lQt5PrintSupport -lQt5Concurrent -lQt5Test -lQt5Sql -lQt5Xml -lQt5Widgets -lQt5OpenGL -lQt5Gui -lQt5PlatformSupport -lQt5Core -lz -licui18n -licuuc

    @/usr/bin/ld: /path/to/my/project/qt/lib/qtbase/libQt5OpenGL.a(qpaintengineex_opengl2.o): previous definition here
    /usr/bin/ld: error: /path/to/my/project/qt/lib/qtbase/libQt5Gui.a(qopenglpaintengine.o): multiple definition of 'QOpenGL2PaintEngineState::~QOpenGL2PaintEngineState()'
    /usr/bin/ld: /path/to/my/project/qt/lib/qtbase/libQt5OpenGL.a(qpaintengineex_opengl2.o): previous definition here
    /usr/bin/ld: error: /path/to/my/project/qt/lib/qtbase/libQt5Gui.a(qopenglpaintengine.o): multiple definition of 'QOpenGL2PaintEngineState::~QOpenGL2PaintEngineState()'
    /usr/bin/ld: /path/to/my/project/qt/lib/qtbase/libQt5OpenGL.a(qpaintengineex_opengl2.o): previous definition here
    /usr/bin/ld: error: /path/to/my/project/qt/lib/qtbase/libQt5Gui.a(qopenglpaintengine.o): multiple definition of 'QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState&)'
    /usr/bin/ld: /path/to/my/project/qt/lib/qtbase/libQt5OpenGL.a(qpaintengineex_opengl2.o): previous definition here
    /usr/bin/ld: error: /path/to/my/project/qt/lib/qtbase/libQt5Gui.a(qopenglpaintengine.o): multiple definition of 'QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState&)'
    /usr/bin/ld: /path/to/my/project/qt/lib/qtbase/libQt5OpenGL.a(qpaintengineex_opengl2.o): previous definition here
    /usr/bin/ld: error: /path/to/my/project/qt/lib/qtbase/libQt5Gui.a(qopenglpaintengine.o): multiple definition of 'QOpenGL2PaintEngineState::QOpenGL2PaintEngineState()'
    /usr/bin/ld: /path/to/my/project/qt/lib/qtbase/libQt5OpenGL.a(qpaintengineex_opengl2.o): previous definition here
    /usr/bin/ld: error: /path/to/my/project/qt/lib/qtbase/libQt5Gui.a(qopenglpaintengine.o): multiple definition of 'QOpenGL2PaintEngineState::QOpenGL2PaintEngineState()'
    /usr/bin/ld: /path/to/my/project/qt/lib/qtbase/libQt5OpenGL.a(qpaintengineex_opengl2.o): previous definition here
    /path/to/my/project/qt/lib/qtbase/libQt5Gui.a(qimage.o):qimage.cpp:function QImage::transformed(QTransform const&, Qt::TransformationMode) const: warning: memset used with constant zero length parameter; this could be due to transposed parameters@

    1 Reply Last reply
    0
    • R Offline
      R Offline
      radman0x
      wrote on last edited by
      #2

      I've provided pretty specific information about the source of the problem, surely someon has an idea of the cause?

      Also I'm compiling on linux and using version Qt 32bit 3.0.2 for linux from here:
      http://download.qt-project.org/official_releases/qt/5.0/5.0.2/single/qt-everywhere-opensource-src-5.0.2.tar.gz

      1 Reply Last reply
      0
      • H Offline
        H Offline
        HoppyIPA
        wrote on last edited by
        #3

        I'm dealing with what appears to be the same problem. I'm trying to do a static build of 5.0.2 on Linux Mint 14. Did you manually add linker options to the configure command line? Can you post the exact configure command you used?

        1 Reply Last reply
        0
        • R Offline
          R Offline
          radman0x
          wrote on last edited by
          #4

          Hi Hoppy,

          I did post the configure line I used:
          ./configure -static -opensource -confirm-license -nomake tests

          You can also find the specific make calls I used above. Can you post your configure and make commands similar to what I have so we can see if your using the same steps?

          1 Reply Last reply
          0
          • H Offline
            H Offline
            HoppyIPA
            wrote on last edited by
            #5

            I've tried several different configurations, but here is the one I'd like to make work:

            @./configure -debug -static -opensource -confirm-license -qt-sql-sqlite -qt-libpng -qt-libjpeg -platform linux-g++-64 -gui -opengl -prefix /usr/local/qt-os-static-5.0.2 -nomake tests -nomake examples -nomake tools@

            I just confirmed that there is indeed multiple definitions in the files you listed.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              radman0x
              wrote on last edited by
              #6

              Seems like no one on the forum here knows anything about this. I'm going to keep investigating, next step getting qt source from the git repo and see if it displays the same error. Will report back once results have been obtained.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                radman0x
                wrote on last edited by
                #7

                I've had success in resolving this issue but it does require modifications to the source code of Qt (although very minor).

                I got the latest code from Git and tested that to see if it had the same behaviour, it did so I started looking into the project files and source more deeply. After a bit of meandering I realised that it was a simple name collision between the headers:
                ./qtbase/src/gui/opengl/qopenglpaintengine_p.h
                ./qtbase/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h

                They were both using QOpenGL2PaintEngineState for a struct in the header. Looking at the opengl target version I noticed the naming convention was to use an abbreviation; QGL2* in preference to QOpenGL2* and that QOpenGL2PaintEngineState didn't follow the pattern. Modifying the name of the struct to follow the QGL2* pattern resolved the issue.
                i.e. I renamed the struct to QGL2PaintEngineState.

                I think the reason it took this long to figure it out is because this should be a very obvious compile error to the Qt maintainers, everyone uses QtGui and QtOpenGL so... I thought perhaps it could be the combo of static, linux build but I suspect a shared library build would have the exact same issue.

                Anyway problem is resolved for me and I will take steps to get the change rolled into Qt.

                Anyone know how I can attach a diff to this? Pasting text doesn't work and there is no attach feature.

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jitowix
                  wrote on last edited by
                  #8

                  [quote author="radman0x" date="1368478490"]I've had success in resolving this issue but it does require modifications to the source code of Qt (although very minor).

                  I got the latest code from Git and tested that to see if it had the same behaviour, it did so I started looking into the project files and source more deeply. After a bit of meandering I realised that it was a simple name collision between the headers:
                  ./qtbase/src/gui/opengl/qopenglpaintengine_p.h
                  ./qtbase/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h

                  They were both using QOpenGL2PaintEngineState for a struct in the header. Looking at the opengl target version I noticed the naming convention was to use an abbreviation; QGL2* in preference to QOpenGL2* and that QOpenGL2PaintEngineState didn't follow the pattern. Modifying the name of the struct to follow the QGL2* pattern resolved the issue.
                  i.e. I renamed the struct to QGL2PaintEngineState.

                  I think the reason it took this long to figure it out is because this should be a very obvious compile error to the Qt maintainers, everyone uses QtGui and QtOpenGL so... I thought perhaps it could be the combo of static, linux build but I suspect a shared library build would have the exact same issue.

                  Anyway problem is resolved for me and I will take steps to get the change rolled into Qt.

                  Anyone know how I can attach a diff to this? Pasting text doesn't work and there is no attach feature.
                  [/quote]

                  Thanks very much, I had the same issue. Unfortunately I've another redefinition errors, with webkit.
                  Here are the logs: http://pastebin.com/0ksWA36A
                  I'd greatly appreciate any help, I'm compiling statically on linux.
                  Command: @./configure -static -developer-build -opensource -confirm-license -nomake examples -nomake tests -no-gtkstyle -release@
                  Thanks.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jitowix
                    wrote on last edited by
                    #9

                    Ok I've fixed my issue by removing "qt/Api/qwebkitplatformplugin.h" from the headers of qtwebkit/Source/WebKit/WebKit1.pro

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      radman0x
                      wrote on last edited by
                      #10

                      Changes submitted and accepted into Qt. The diff can be seen on gerrit "here":https://codereview.qt-project.org/#change,56607.

                      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