flutter编译Linux版本的桌面端程序报错

1、/usr/bin/ld: 找不到 -lstdc++: 没有那个文件或目录

CMake Error at /home/allan/apps/cmake-3.26.1-linux-x86_64/share/cmake-3.26/Modules/CMakeTestCXXCompiler.cmake:60 (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/allan/work/file-server/fileclient/build/linux/x64/debug/CMakeFiles/CMakeScratch/TryCompile-nmxh4O

    Run Build Command(s):/usr/bin/ninja -v cmTC_2711a && [1/2] /usr/bin/clang++    -MD -MT CMakeFiles/cmTC_2711a.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_2711a.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_2711a.dir/testCXXCompiler.cxx.o -c /home/allan/work/file-server/fileclient/build/linux/x64/debug/CMakeFiles/CMakeScratch/TryCompile-nmxh4O/testCXXCompiler.cxx
    [2/2] : && /usr/bin/clang++   CMakeFiles/cmTC_2711a.dir/testCXXCompiler.cxx.o -o cmTC_2711a   && :
    FAILED: cmTC_2711a 
    : && /usr/bin/clang++   CMakeFiles/cmTC_2711a.dir/testCXXCompiler.cxx.o -o cmTC_2711a   && :
    /usr/bin/ld: 找不到 -lstdc++: 没有那个文件或目录
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.





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


Unable to generate build files

clang++ 找到了错误的gcc-13,但系统中gcc-13并不完整

使用clang++直接编译helloword文件也提示缺库。

解决方法:

# 卸载旧版本
sudo apt purge gcc-13 clang
# 重新安装新版本
sudo apt install clang

再装一次clang免得自己手动配置,解决了问题

2、 file INSTALL cannot copy file

Building Linux application...                                   
CMake Error at cmake_install.cmake:66 (file):
  file INSTALL cannot copy file
  "/home/allan/work/file-server/fileclient/build/linux/x64/debug/intermediates_do_not_run/fileclient"
  to "/usr/local/fileclient": Success.


Build process failed

这是因为linux缓存目录生成的信息跟本系统不匹配导致的。
解决方法

flutter clean && flutter pub get