Flutter Error: cmake error : debugging new project
Asked Answered
I

3

7

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?

Infinitude answered 28/5, 2022 at 19:22 Comment(3)
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.Croner
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 filesInfinitude
Post a new question with the full output.Croner
I
10

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

Infinitude answered 29/5, 2022 at 3:26 Comment(1)
also need : sudo apt install libstdc++-12-devStreusel
M
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

Mounts answered 9/4 at 7:44 Comment(0)
S
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

Sort answered 25/9, 2022 at 12:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.