CMAKE_CXX_COMPILER_VERSION is pointing to the old GCC version - c++

I have upgraded my GCC using:
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-8 g++-8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 70 --slave /usr/bin/g++ g++ /usr/bin/g++-8
Running any of these commands:
$ gcc --version
$ g++ --version
$ c++ --version
$ /usr/bin/gcc --version
$ /usr/bin/g++ --version
$ /usr/bin/c++ --version
would show (Ubuntu 8.1.0-5ubuntu1~16.04) 8.1.0 confirming that version 8.1 has been installed.
When running ./configure on cmake-3.12.1 I downloaded from its website I get:
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
However when trying to make my actual project:
CMake Error at CMakeLists.txt:24 (message):
GCC version must be at least 7.1! 5.4.0
This is my CMakeLists.txt:
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# require at least gcc 7.1
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.1)
message(FATAL_ERROR "GCC version must be at least 7.1! " ${CMAKE_CXX_COMPILER_VERSION})
endif()
endif()

As Shawn, Tsyvarev and hellow have mentioned in the comments, this problem is caused by CMake cache file which was located inside /build/. Deleting the file solved the issue.

Related

Qt how to change to C++17

I couldn't perform #include <variant> in Qt 5.14. I've tried to change the .pro file by adding CONFIG += c++17 or CONFIG += c++1z warn_on or QMAKE_CXXFLAGS += -std=c++17 but none of them work.
Any fix to this?
The reason that my Qt doesnt recognize variant module is because it is run by gcc-5. So I updated gcc and g++ to version 7:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7 -y
This is to update the symbolic links to version 7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo update-alternatives --config gcc
gcc --version
g++ --version

header file <execution> missing in gcc 7.2 (Ubuntu) : how to solve it?

few days ago I updated in my Ubuntu 16.04 Server Edition gcc to gcc 7.2 version:
gcc version 7.2.0 (Ubuntu 7.2.0-1ubuntu1~16.04)
which should be the most updated version of gcc available for Ubuntu
Now, compiling an example of a book,
g++ -std=c++17 auto_parallel.cpp -oauto_parallel
auto_parallel.cpp:5:10: fatal error: execution: No such file or directory
include <execution>
~~~~~~~~~~
compilation terminated.
How to solve the problem?
Thanks in advance. Marco
update your GUN compiler to version9, according to(https://en.cppreference.com/w/cpp/compiler_support
and https://www.bojankomazec.com/2020/03/upgrading-gnu-cc-compilers-on-ubuntu.html)
sudo apt install -y gcc-9 g++-9 -y
and remap your compiler to gcc-9
sudo rm /usr/bin/g++
sudo ln -s /usr/bin/g++-9 /usr/bin/g++
sudo rm /usr/bin/gcc
sudo ln -s /usr/bin/gcc-9 /usr/bin/gcc
Verify the compiler version
ls -la /usr/bin/gcc
ls -la /usr/bin/g++

While installing on OSX Sierra via gcc-6, keep having "FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!" error

Environment info
Operating System:
macOS 10.12.2 (16C68)
Compiler:
gcc-6
Steps to reproduce
I've installed gcc-6 and modified config.mk as required into
export CC = gcc-6
export CXX = g++-6
But keep having this error:
g++-6 -c -std=c++0x -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -O3 -funroll-loops -msse2 -fPIC -fopenmp src/learner.cc -o build/learner.o
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
What have you tried?
Reinstall XCode
Reinstall gcc
Run make clean_all && make -4j
But still went wrong. Any idea?
I had this issue when using macports-installed gnu assembler. You could try forcing the use of as that comes with Xcode, or simply temporarily removing /opt/local/bin from your path.
I solved by uninstalling MacPorts:
sudo port -f uninstall installed

capybara-webkit on yosemite g++: error: unrecognized command line option '-Xarch_x86_64'

I'm having problem installing on OS X 10.10 Yosemite, running with gcc4.9.2 and qt 4.8.6 installed via Brew.
gem install capybara-webkit
Building native extensions. This could take a while...
ERROR: Error installing capybara-webkit:
ERROR: Failed to build gem native extension.
/usr/local/var/rbenv/versions/2.1.4/bin/ruby extconf.rb
cd src/ && /usr/local/bin/qmake /usr/local/rbenv/gem/gems/capybara-webkit-1.3.1/src/webkit_server.pro -spec /usr/local/Cellar/qt/4.8.6/mkspecs/macx-g++ -o Makefile.webkit_server
cd src/ && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f Makefile.webkit_server
g++ -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.8.6/mkspecs/macx-g++ -I. -I/usr/local/Cellar/qt/4.8.6/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtNetwork.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtNetwork.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtWebKit.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtWebKit.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/include -Ibuild -F/usr/local/Cellar/qt/4.8.6/lib -x c++-header -c stable.h -o build/webkit_server.gch/c++
g++: error: unrecognized command line option '-Xarch_x86_64'
make[1]: *** [build/webkit_server.gch/c++] Error 1
make: *** [sub-src-webkit_server-pro-make_default-ordered] Error 2
Command 'make' failed
I had the same problem using GCC installed via MacPorts (tested several versions up to gcc5). The solution for me was using g++ supplied with the XCode command line tools. I uninstalled all MacPorts GCC versions. Below version details of the g++ command that worked.
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
A similar problem was asked here: QT Creator adds -Xarch.

LLVM Clang 5.0 explicit in copy-initialization error

I'm trying to compile an open source project on OSX that has only been tested on Linux.
$: g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-da
I'm trying to compile with the following command line options
g++ -MMD -Wall -std=c++0x -stdlib=libc++ -Wno-sign-compare -Wno-unused-variable -ftemplate-depth=1024 -I /usr/local/Cellar/boost/1.55.0/include/boost/ -g -O3 -c level.cpp -o obj-opt/level.o
I am seeing several errors that look like this:
./square.h:39:70: error: chosen constructor is explicit in copy-initialization
int strength = 0, double flamability = 0, map<SquareType, int> constructions = {}, bool ticking = false);
The project states the following are requirements for the Linux setup. How can I confirm I'm making that?
gcc-4.8.2
git
libboost 1.5+ with libboost-serialize
libsfml-dev 2+ (Ubuntu ppa that contains libsfml 2: )
freeglut-dev
libglew-dev
The project requires you to compile with gcc-4.8.2 , but your g++ is using clang, which is a different compiler.
Install gcc-4.8.2 or above, and use it to compile your project
$ sudo port install gcc49