#3990 closed defect (fixed)
Build errors with Qt 5.7 and clang (needs C++11)
Reported by: | Owned by: | Martin Sjölund | |
---|---|---|---|
Priority: | high | Milestone: | 1.11.0 |
Component: | OMNotebook | Version: | |
Keywords: | Cc: |
Description
Qt >= 5.7.0
will require a C++11 compliant compiler to build.
On archlinux with gcc-6.1.1
and qt-5.7.0
OpenModelica master branch builds and runs fine without any changes.
Using clang-3.8.0
and qt-5.7.0
gives build errors like this from OMShellGUI:
In file included from commandcompletion.cpp:49: In file included from /usr/include/qt/QtCore/QFile:1: In file included from /usr/include/qt/QtCore/qfile.h:44: In file included from /usr/include/qt/QtCore/qfiledevice.h:43: In file included from /usr/include/qt/QtCore/qiodevice.h:43: In file included from /usr/include/qt/QtCore/qglobal.h:1145: In file included from /usr/include/qt/QtCore/qatomic.h:46: /usr/include/qt/QtCore/qbasicatomic.h:61:4: error: "Qt requires C++11 support"
Simply adding -std=c++11
to the CXXFLAGS
doesn't help, as in the qmake config files like OMEdit.config.in the CFLAGS
and CPPFLAGS
will be propagated to QMAKE_CXXFLAGS
.
It's also not possible to add -std=c++11
to CFLAGS
, as clang then raises an error at configure:
configure:2143: checking whether the C compiler works configure:2165: clang -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -std=c++11 -D_FORTIFY_SOURCE=2 -DH5_USE_18_API -Wl,-O1,--sort-common,--as-needed,-z,relro conftest.c >&5 error: invalid argument '-std=c++11' not allowed with 'C/ObjC'
I got it to work by adding the following changes to the qmake config files in my PKGBUILD before configure:
export CXXFLAGS="$CXXFLAGS -std=c++11" sed -i 's/QMAKE_CXXFLAGS = @CFLAGS@ @CPPFLAGS@$/QMAKE_CXXFLAGS = @CFLAGS@ @CPPFLAGS@ @CXXFLAGS@/' ./OMEdit/OMEdit/OMEditGUI/OMEdit.config.in sed -i 's/QMAKE_CXXFLAGS = @CFLAGS@ @CPPFLAGS@$/QMAKE_CXXFLAGS = @CFLAGS@ @CPPFLAGS@ @CXXFLAGS@/' ./OMNotebook/OMNotebook/OMNotebookGUI/OMNotebook.config.in sed -i 's/QMAKE_CXXFLAGS = @CFLAGS@ @CPPFLAGS@$/QMAKE_CXXFLAGS = @CFLAGS@ @CPPFLAGS@ @CXXFLAGS@/' ./OMShell/OMShell/OMShellGUI/OMShell.config.in sed -i 's/QMAKE_CXXFLAGS = @CFLAGS@ @CPPFLAGS@$/QMAKE_CXXFLAGS = @CFLAGS@ @CPPFLAGS@ @CXXFLAGS@/' ./OMPlot/OMPlot/OMPlotGUI/OMPlotGUI.config.in sed -i 's/#QMAKE_CXXFLAGS \*= -std=c++11$/QMAKE_CXXFLAGS *= -std=c++11/' ./OMPlot/qwt/qwtbuild.pri
Change History (3)
comment:1 by , 8 years ago
Component: | *unknown* → OMNotebook |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Summary: | Build errors with Qt 5.7 and clang → Build errors with Qt 5.7 and clang (needs C++11) |
comment:2 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed in 87a6e8b/OMNotebook and 3464745/OMShell.
comment:3 by , 7 years ago
Milestone: | Future → 1.11.0 |
---|
The problem is fixed for OMEdit and OMPlot (including qwt) by the commits 19a274 and f907e8, respectively.
The C++11 compiler flag should also be added to QMAKE_CXXFLAGS for OMNotebook and OMShell to close this issue.