11

I just start a new flutter project in vscode , when I want debugging the project , I got Error:

  Could not find compiler set in environment variable CXX:

  clang++.

Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
Exception: Unable to generate build files

I search on internet , and I found my "cmake" package , doesn't have g++.exe , so install it manually by following command line:

sudo apt-get install g++

but it doesn't work , how can I solve it?

3
  • 1
    Your CXX environment variable seems to be set to clang++, not g++. So either you need to install clang++ or you need to configure your environment better. Commented May 28, 2022 at 19:28
  • I install clang using following command line: sudo apt-get install clang and i get a new error : CMake Error at /usr/share/cmake-3.16/Modules/FindPkgConfig.cmake:463 (message): A required package was not found Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/FindPkgConfig.cmake:643 (_pkg_check_modules_internal) flutter/CMakeLists.txt:25 (pkg_check_modules) 2 Exception: Unable to generate build files Commented May 28, 2022 at 19:58
  • Post a new question with the full output. Commented May 28, 2022 at 20:01

4 Answers 4

18

I found the solution:

1- first run this command line :

sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev

2- run flutter clean , but you must run it from your project root , done!

source : here

Sign up to request clarification or add additional context in comments.

1 Comment

also need : sudo apt install libstdc++-12-dev
1

I run this command on my Ubuntu 22.04 and it worked for me : sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev clang cmake ninja-build pkg-config libgtk-3-dev libboost-all-dev libsecret-1-dev libjsoncpp-dev libsecret-1-0

Comments

1

For me
using sh not work on vscode

how to make sure there is wrong ?

  • try inside terminal of vscode flutter doctor

there is wrong?

  • switch to bash in same page there is sign + choose bash

not work?

  • try Linux (if using it) from terminal run flutter doctor

everything well,NO?

  • try to install clang-14 or clang-19

More

Could not find compiler set in environment variable CXX: clang++. #61418
good luck

Comments

0

You can set the variables CMAKE_CXX_COMPILER, CMAKE_C_COMPILER in the linux/CMakeLists.txt before project() line

set ( CMAKE_CXX_COMPILER "pathto/g++" )
set ( CMAKE_C_COMPILER "/pathto/gcc" )
project(mytest)

source: CMAKE_C_COMPILER not set, after EnableLanguage

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.