Score:0

Cmake can't find gcc compiler

nl flag

I have Ubuntu 18.04.6 LTS and I am trying to install and run gcc v8 (a v7 version is the default).

I have done: sudo apt-get install build-essential

sudo apt-get install gcc-8

To try to get the v8 to be default I did: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g++-7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8

If I run gcc -v I get:

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.4.0-1ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 8.4.0 (Ubuntu 8.4.0-1ubuntu1~18.04)

But running make all -j I get:

git submodule init git submodule update --init --recursive mkdir -p build && cd build && cmake .. -- CMAKE_BUILD_TYPE: Release -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:42 (project): The CMAKE_CXX_COMPILER:

/usr/bin/c++

is not a full path to an existing compiler tool.

Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred!

Another similar post recommended build-essential but I already have that - what do I need to do to fix it?

Many thanks for any help!

hr flag
So did you try the suggested remedy of setting the CXX environment variable? ex. `export CXX=/usr/bin/g++-8` before running `make`
nl flag
No I hadn't, I didn't know what to set it to - did as you suggested but g++-8 does not exist...
hr flag
Did you install it? I assumed so since you apparently added it as a slave with update-alternatives. If you didn't, then please do so (`sudo apt install g++-8`)
nl flag
gcc-7, g++-7 and gcc-8 exist but /usr/bin/g++-8 is not there - am I missing an install?
hr flag
Likely yes - `g++-8` is a separate package, installing `gcc-8` on its own is not sufficient
nl flag
Yes it was missing - installed it - still no joy! Same message...
nl flag
Its looking for /usr/bin/c++ which is a link to /etc/alternatives/c++ which is a link to /usr/bin/g++ which doesn't exist...
cc flag
Take a look at https://askubuntu.com/questions/1370061/i-am-using-ubuntu-20-04-lts-trying-to-get-from-gcc-9-4-to-gcc-10-or-higher/1370140#1370140 which has some suggestions for the equivalent gcc situation.
nl flag
OK, @ubfan1, I looked at the post and re-ran update-alternatives and that has fixed it!
nl flag
Many thanks to everyone, compiler found.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.