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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With