LoginSignup
0

More than 1 year has passed since last update.

No CMAKE_CXX_COMPILER could be found.

Posted at

エラーの意味

CMAKE_<LANG>_COMPILERはコンパイラへのフルパスという意味なので, 記事タイトルのエラーの意味は「C++のコンパイラへが見つかりません」という意味

やろうとしていたこと

CentOS7にdevtoolset-8を使ってgccをインストールしようとしていたら, 記事タイトルのエラーが出た

調査

まずはgccg++コンパイラへのパスが通っているかを確認する

> gcc --version
 gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
 Copyright (C) 2015 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> g++ --version
 bash: g++: command not found

あれ, gccとg++をインストールしたのにパスが通っていない?

解決

sudo yum install -y centos-release-scl
sudo yum install -y devtoolset-8

を実行した後にdevtoolset-8を有効にしていなかったのが原因だった.

scl enable devtoolset-8 -- bash

を使えば, devtoolssetgccおよびg++が使えるようになる.

Dockerを使いたい場合

dockerfileの各行頭に scl enable devtoolset-8 -- bash &&を足すのは流石に面倒なのでSHELLを使う.

dockerfile
 SHELL [ "/usr/bin/scl", "enable", "devtoolset-8"]

How to permanently enable scl CentOS 6.4?

以上.

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0