﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3990	Build errors with Qt 5.7 and clang (needs C++11)	spinnau@…	Martin Sjölund	"`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 [https://github.com/OpenModelica/OMEdit/blob/master/OMEdit/OMEditGUI/OMEdit.config.in#L13 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
}}}

 

"	defect	closed	high	1.11.0	OMNotebook		fixed		
