I am not able to run flutter application (linux development)

Asked by Ali_Niaz

I am facing a problem last two days..
I want to use flutter for Linux development (as it is part of college course), all of the requirements is full filled that flutter wants.
(Here is my flutter doctor)
```
Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

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

[✓] VS Code (version 1.77.3)
    • VS Code at /usr/share/code
    • Flutter extension version 3.62.0

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.2 LTS 5.19.0-40-generic

[✓] HTTP Host Availability
    • All required HTTP hosts are available
```

below is the problem with clang

```
[ +7 ms] CMake Error at
/usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
[ +27 ms] The C++ compiler
[ +2 ms] "/usr/bin/clang++"
[ +2 ms] is not able to compile a simple test program.
[ +1 ms] It fails with the following output:
[ +1 ms] Change Dir:
/media/ali-niaz/62F060ECF060C7BD/Linux/flutter_dev/first/build/linux/x64/debug/C
MakeFiles/CMakeTmp
[ +2 ms] Run Build Command(s):/usr/bin/ninja cmTC_e6945 && [1/2] Building
CXX object CMakeFiles/cmTC_e6945.dir/testCXXCompiler.cxx.o
[ +1 ms] [2/2] Linking CXX executable cmTC_e6945
[ +1 ms] FAILED: cmTC_e6945
[ +1 ms] : && /usr/bin/clang++
CMakeFiles/cmTC_e6945.dir/testCXXCompiler.cxx.o -o cmTC_e6945 && :
[ +2 ms] /usr/bin/ld: cannot find -lstdc++: No such file or directory
[ +1 ms] clang: error: linker command failed with exit code 1 (use -v to
see invocation)
[ +1 ms] ninja: build stopped: subcommand failed.
[ +1 ms] CMake will not be able to correctly generate this project.
[ +1 ms] Call Stack (most recent call first):
[ +14 ms] CMakeLists.txt:3 (project)

```
thanks in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Ali_Niaz
Solved:
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

For diagnostic purposes, what is the output that you receive for the following commands:

uname -a
lsb_release -crid
dpkg -l | grep clang
apt policy libstdc++6 libstdc++-11-dev
ls -l /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++*

Revision history for this message
Ali_Niaz (aliniaz) said :
#2

The output is listed below all from 1 to 5. I just tried to format a bit to improve readability (i didn't change any thing).

------ 1 -------
uname -a
---------------
Linux aliniaz-ThinkPad-X140e 5.19.0-40-generic #41~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 31 16:00:14 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

---------- 2 -------------
lsb_release -crid
-------------------------
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy

---------- 3 --------------
dpkg -l | grep clang
---------------------------
ii clang 1:14.0-55~exp2 amd64 C, C++ and Objective-C compiler (LLVM based), clang binary
ii clang-11 1:11.1.0-6 amd64 C, C++ and Objective-C compiler
ii clang-14 1:14.0.0-1ubuntu1 amd64 C, C++ and Objective-C compiler
ii libclang-common-11-dev 1:11.1.0-6 amd64 Clang library - Common development package
ii libclang-common-14-dev 1:14.0.0-1ubuntu1 amd64 Clang library - Common development package
ii libclang-cpp11 1:11.1.0-6 amd64 C++ interface to the Clang library
ii libclang-cpp14 1:14.0.0-1ubuntu1 amd64 C++ interface to the Clang library
ii libclang1-11 1:11.1.0-6 amd64 C interface to the Clang library
ii libclang1-14 1:14.0.0-1ubuntu1 amd64 C interface to the Clang library

-------------------------- 4 -----------------------------
apt policy libstdc++6 libstdc++-11-dev
----------------------------------------------------------
libstdc++6:
  Installed: 12.1.0-2ubuntu1~22.04
  Candidate: 12.1.0-2ubuntu1~22.04
  Version table:
 *** 12.1.0-2ubuntu1~22.04 500
        500 http://pk.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
        100 /var/lib/dpkg/status
     12-20220319-1ubuntu1 500
        500 http://pk.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
libstdc++-11-dev:
  Installed: 11.3.0-1ubuntu1~22.04
  Candidate: 11.3.0-1ubuntu1~22.04
  Version table:
 *** 11.3.0-1ubuntu1~22.04 500
        500 http://pk.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
        100 /var/lib/dpkg/status
     11.2.0-19ubuntu1 500
        500 http://pk.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

------------------------------- 5 ----------------------------------------
ls -l /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++*
---------------------------------------------------------------------------
-rw-r--r-- 1 root root 6020004 May 1 2022 /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a
-rw-r--r-- 1 root root 685326 May 1 2022 /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++fs.a
lrwxrwxrwx 1 root root 40 May 1 2022 /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.so -> ../../../x86_64-linux-gnu/libstdc++.so.6

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

Digging further based on your previous output, what is the output of the commands

apt policy libstdc++-12-dev
ls -l /usr/lib/gcc/x86_64-linux-gnu/12/libstdc++*
ls -l /usr/lib/x86_64-linux-gnu/libstdc++*

Revision history for this message
Ali_Niaz (aliniaz) said :
#4

--------------- 1 -----------------------
apt policy libstdc++-12-dev
-----------------------------------------
libstdc++-12-dev:
  Installed: (none)
  Candidate: 12.1.0-2ubuntu1~22.04
  Version table:
     12.1.0-2ubuntu1~22.04 500
        500 http://pk.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages
     12-20220319-1ubuntu1 500
        500 http://pk.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

------------------------ 2 ---------------------------------------------
ls -l /usr/lib/gcc/x86_64-linux-gnu/12/libstdc++*
-----------------------------------------------------------------------
ls: cannot access '/usr/lib/gcc/x86_64-linux-gnu/12/libstdc++*': No such file or directory
ali-niaz@aliniaz-Thi
( the command is valid upto ls -l /usr/lib/gcc/x86_64-linux-gnu/12/ but the file libstdc++* is missing in directory named 12)

--------------------------- 3 -------------------------------
ls -l /usr/lib/x86_64-linux-gnu/libstdc++*
--------------------------------------------------------------
lrwxrwxrwx 1 root root 19 Apr 23 16:29 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.30
-rw-r--r-- 1 root root 2252096 May 13 2022 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30

Revision history for this message
Ali_Niaz (aliniaz) said :
#5

I run the following command
-------------------------------------------------------
sudo apt-get install libstdc++-12-dev
-------------------------------------------------------

and after run your command.
------------------------ 2 ---------------------------------------------
ls -l /usr/lib/gcc/x86_64-linux-gnu/12/libstdc++*
-----------------------------------------------------------------------
-rw-r--r-- 1 root root 6107632 May 13 2022 /usr/lib/gcc/x86_64-linux-gnu/12/libstdc++.a
-rw-r--r-- 1 root root 721546 May 13 2022 /usr/lib/gcc/x86_64-linux-gnu/12/libstdc++fs.a
lrwxrwxrwx 1 root root 40 May 13 2022 /usr/lib/gcc/x86_64-linux-gnu/12/libstdc++.so -> ../../../x86_64-linux-gnu/libstdc++.so.6

(The above is the result of 2nd command)

So this time with a different error msg.

```
[ +19 ms] CMake Error at cmake_install.cmake:66 (file):
[ +30 ms] file INSTALL cannot copy file
[ +1 ms] "/home/ali-niaz/Desktop/flutter_dev/first/build/linux/x64/debug/intermediates_do_not_run/first"
[ +1 ms] to "/usr/local/first": Permission denied.
[ +13 ms] FAILED: CMakeFiles/install.util
[ +6 ms] cd /home/ali-niaz/Desktop/flutter_dev/first/build/linux/x64/debug && /usr/bin/cmake -P cmake_install.cmake
[ +1 ms] ninja: build stopped: subcommand failed.
[ +84 ms] Building Linux application... (completed in 38.2s)
[+33515 ms] Exception: Build process failed
[ +17 ms] "flutter run" took 75,442ms.
[ +49 ms]
           #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:722:9)
           <asynchronous suspension>
           #2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1257:27)
           <asynchronous suspension>
           #3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #4 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #5 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:283:9)
           <asynchronous suspension>
           #6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
           <asynchronous suspension>
           #9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10 main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>

[ +262 ms] ensureAnalyticsSent: 252ms
[ +1 ms] Running 1 shutdown hook
[ +48 ms] Shutdown hooks complete
[ +4 ms] exiting with code 1

```

I tried to change chmod 777 of the usr directory but it didn't worked
------------------------
chmod 777 usr/
------------------------
chmod: changing permissions of 'usr/': Operation not permitted

Revision history for this message
Manfred Hampl (m-hampl) said :
#6

When looking at the initial question, I see

[!] Android Studio (not installed)

Have you already coped with that?

Revision history for this message
Ali_Niaz (aliniaz) said :
#7

No I didn't install Android Studio, I want to use VS Code as I do in my windows machine.

Revision history for this message
Manfred Hampl (m-hampl) said :
#8

What was the command that you entered to receive the output in comment #5?

Revision history for this message
Ali_Niaz (aliniaz) said :
#9

flutter run -v

Revision history for this message
Ali_Niaz (aliniaz) said :
#10

Ohhh
Finally I run flutter clean and then flutter run
It just starts working.
Thank you so very much, you saved me man thank you.