Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake Error on linux (Flutter project in Android Studio)

When I create a new Flutter project in Android Studio (Android Studio Electric Eel | 2022.1.1), I build an APK and run it on the android emulator with no problem, but when I try to run it on linux I get this error:

CMake Error at /usr/share/cmake-3.25/Modules/CMakeDetermineCXXCompiler.cmake:48 (message):
    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

My system (Pop!_OS 22.04 LTS) doesn't have that version of CMake installed, it has /usr/share/cmake-3.22 installed

And in Android Studio settings, under System Settings -> Android SDK -> SDK Tools, CMake 3.22.1 is installed

I am not able to figure out how to adjust the CMake version in Android Studio and what is the correct solution. Please any ideas?

like image 479
Webierta Avatar asked Apr 18 '26 22:04

Webierta


1 Answers

SOLVED!

In the CMakeKists.txt file (in the /linux folder) I have added at the beginning (I think it has to be before the project(runner LANGUAGES CXX) line):

set(CMAKE_CXX_COMPILER "/usr/bin/g++")

Now it runs on linux with no problems.

EDIT (best solution):

sudo apt install lib32stdc++-12-dev
like image 143
Webierta Avatar answered Apr 20 '26 12:04

Webierta