Flutter linux 构建错误:cmake 无法编译简单的测试程序

问题描述 投票:0回答:1

我一直在使用 Flutlab 开发我的第一个 Flutter 应用程序,并且最近在 vscode 中进行了设置。在网络模拟器中一切正常,但当我尝试在 Linux 上运行时,出现以下错误:

Launching lib/main.dart on Linux in debug mode...
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler

    "/usr/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/user/Downloads/Code/app/build/linux/x64/debug/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/ninja cmTC_5004a && [1/2] Building CXX object CMakeFiles/cmTC_5004a.dir/testCXXCompiler.cxx.o
    [2/2] Linking CXX executable cmTC_5004a
    FAILED: cmTC_5004a 
    : && /usr/bin/clang++   CMakeFiles/cmTC_5004a.dir/testCXXCompiler.cxx.o -o cmTC_5004a   && :
    /usr/bin/ld: cannot find -lstdc++: No such file or directory
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.
5

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:7 (project)
2

Error: Unable to generate build files

Exited (1).

这里有一些附加信息:

系统:

操作系统:Kubuntu 22.04 KDE 等离子版本:5.24.7 KDE 框架版本:5.98.0 Qt版本:5.15.3 内核版本:5.15.0-100-generic(64位) 图形平台:X11

VS代码:

版本:1.87.1 提交:1e790d77f81672c49be070e04474901747115651 日期:2024-03-06T00:21:07.287Z 电子:27.3.2 电子构建 ID:26836302 铬:118.0.5993.159 Node.js:18.17.1 V8:11.8.172.18-电子.0 操作系统:Linux x64 5.15.0-100-generic

颤动:

Flutter 3.19.3 • 通道稳定 • https://github.com/flutter/flutter.git 框架 • 修订版 ba39319843(2 天前) • 2024-03-07 15:22:21 -0600 引擎 • 修订版 2e4ba9c6fb 工具 • Dart 3.3.1 • DevTools 2.31.1

飞镖:

Dart SDK 版本:3.3.1(稳定)(2024 年 3 月 6 日星期三 13:09:19 +0000)在“linux_x64”上

cmake 版本 3.22.1

我已经尝试过:

清除并重新安装 clang --> 没有任何改变

尝试手动添加路径 --> 在我的文件资源管理器中的无数搜索结果中找不到正确的路径,我当然检查了 libstdc++6 是否与通常的 build-essential 和 g++ 一起安装了

现在我不太熟悉 c++ 或 cmake,所以我一直在尽力排除故障,但如果有人知道如何解决这个问题,那将是一个救星。 如果还有什么需要了解的请询问。

c++ flutter dart cmake clang++
1个回答
0
投票

构建配置告诉编译器使用 GCC 中的 GNU 标准 C++ 库。

安装

sudo apt install libstdc++-dev
© www.soinside.com 2019 - 2024. All rights reserved.