Qt5 static build has multiple defined symbols on link
-
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.hConfigure:
./configure -static -opensource -confirm-license -nomake testsMake:
make module-qtbase
make module-qtdeclarativeLink: (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@ -
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 -
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?
-
Hi Hoppy,
I did post the configure line I used:
./configure -static -opensource -confirm-license -nomake testsYou 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?
-
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.
-
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.
-
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.hThey 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 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.hThey 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. -
Ok I've fixed my issue by removing "qt/Api/qwebkitplatformplugin.h" from the headers of qtwebkit/Source/WebKit/WebKit1.pro
-
Changes submitted and accepted into Qt. The diff can be seen on gerrit "here":https://codereview.qt-project.org/#change,56607.