Brock Sawlor
Brock Sawlor

Reputation: 21

CMake Error: CMAKE_CXX_COMPILER not set when building Flutter app on Ubuntu

Was working on a namer_app example based on the video below. I created a new project to check as the dart sdk wasn't being referenced in the initial app:

import 'package:integration_test/integration_test_driver.dart' as driver;  target of uri doesn't exist

That seemed to work, but the flutter sdk is still pointing to the first project (trying to follow this video)

Ubuntu 24.04.1 x64 6.8.1-51-generic VS Code - 1.96.1 Chrome - Version 131.0.6778.204 (Official Build) (64-bit)

VSCode Extensions:

Android Studio Ladybug | 2024.2.1 Patch 3
Build #AI-242.23339.11.2421.12700392, built on November 22, 2024
Runtime version: 21.0.3+-12282718-b509.11 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.X11.XToolkit
Linux 6.8.0-51-generic
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 4002M
Cores: 24
Registry:
  ide.experimental.ui=true
  i18n.locale=
Non-Bundled Plugins:
  Dart (242.24931)
  de.cusp.cu.curNotesMDs (1.0.0)
  io.flutter (83.0.3)
Current Desktop: ubuntu:GNOME

in .bashrc

export PATH="$PATH:/snap/bin/flutter/bin"
export PATH="$PATH:/usr/bin/java"
PATH=$PATH:/home/[user]/Projects/namer_app/lib/flutter/bin
#export JAVA_HOME=/usr/lib/jvm/java-1.21.0-openjdk-amd64
#export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
export JAVA_HOME=/usr/bin/java
export ANDROID_SDK_ROOT=/home/[user]/Android/Sdk

clang version

clang -v
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64

in VSCode, flutter doctor response

[flutter] flutter doctor -v
[!] Flutter (Channel stable, 3.24.3, on Freedesktop SDK 24.08 (Flatpak runtime) 6.8.0-51-generic, locale en_US.UTF-8)
    • Flutter version 3.24.3 on channel stable at /home/[user]/Projects/namer_app/lib/flutter
    ! The flutter binary is not on your path. Consider adding /home/[user]/Projects/namer_app/lib/flutter/bin to your path.
    ! The dart binary is not on your path. Consider adding /home/[user]/Projects/namer_app/lib/flutter/bin to your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (4 months ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/brock/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /usr/lib/jvm/java-1.21.0-openjdk-amd64/bin/java
    ✗ Cannot execute /usr/lib/jvm/java-1.21.0-openjdk-amd64/bin/java to determine the version

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✗] Linux toolchain - develop for Linux desktop
    ✗ clang++ is required for Linux development.
      It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/
    • cmake version 3.31.2
    • ninja version 1.12.1
    • pkg-config version 2.3.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).

[✓] VS Code (version 1.96.2)
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.96.0

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Freedesktop SDK 24.08 (Flatpak runtime) 6.8.0-51-generic

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 5 categories.
exit code 0

Android Studio, Chrome and clang are installed (versions above), so I know flutter doctor isn't thorough when checking.

I was having java issues, but now clang is causing a issue when debugging.

Downloading linux-x64-debug/linux-x64-flutter-gtk tools...
Downloading linux-x64-profile/linux-x64-flutter-gtk tools...
Downloading linux-x64-release/linux-x64-flutter-gtk tools...
Launching lib/main.dart on Linux in debug mode...
CMake Error at /usr/share/cmake-3.31/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)
2

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

Exited (1).

The original namer app still has the uri errors when I try to debug it, along with the clang cmake error.

Was trying some suggestions here

Hoping to get this working, it was when I initially started going through the video (a few months ago), but updates broke the java/dart sdk reference.

Upvotes: 2

Views: 52

Answers (0)

Related Questions