8
9

More than 5 years have passed since last update.

Cannot find compiler 'cl.exe' in PATH

Posted at

Cannot find compiler 'cl.exe' in PATH

問題

VisualStudio2017をインストールして、C++環境もいれたはずなのにclのパスが通ってないよっていうエラーがでた。

エラー文
Cannot find compiler 'cl.exe' in PATH

解決策

前提

C/C++ コンパイラ (cl.exe) をVisualStudio Installer でC++によるデスクトップ開発からインストール済み

CLとは

Microsoft Visual C++のコンパイラ本体

場所

エクスプローラを開いて下記のパスをみると、

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64

こんなかんじのやつがいる。
Baidu IME_2018-12-23_4-48-37.jpg
こいつが目的のcl.exeである。x86が32bitで、x64が64bit用である。

パスを通す

コントロール パネル->システムとセキュリティ->システムと開く。
次にシステムの詳細設定->環境変数と開く。
システム環境変数->Pathを選択し、編集で開く。
新規追加で、パスをいれたらOKを押して終了。

確認

コマンドプロンプトを再起動して、clとうって下記のものが出ればOK。

>cl
Microsoft(R) C/C++ Optimizing Compiler Version 19.16.27025.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

使い方: cl [ オプション... ] ファイル名... [ /link リンク オプション... ]

参考

8
9
2

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
8
9