Flutter Linux build error when executing flutter run -d linux
Asked Answered
F

5

4

Flutter doctor did not show any issues. What could be wrong?

executing: flutter run -d linux

Shows the following:

CMake Error at /snap/flutter/81/usr/share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 (message): The C++ compiler

"/snap/flutter/current/usr/bin/clang++"                             
                                                                    

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/work/AndroidStudioProjects/myapp/build/linux/x64/debug/CMakeFiles/CMakeTmp
                                                                    
Run Build Command:"/snap/flutter/current/usr/bin/ninja" "cmTC_0475b"
[1/2] Building CXX object CMakeFiles/cmTC_0475b.dir/testCXXCompiler.cxx.o
[2/2] Linking CXX executable cmTC_0475b                             
FAILED: cmTC_0475b       
 : && /snap/flutter/current/usr/bin/clang++    -L/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/8 -L/snap/flutter/current/usr/lib/x86_64-linux-gnu -lblkid -lgcrypt -llzma -lpthread -L/snap/flutter/current/usr/lib/ -L/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/8 -L/snap/flutter/current/usr/lib/x86_64-linux-gnu -lblkid -lgcrypt -llzma -lpthread -L/snap/flutter/current/usr/lib/ CMakeFiles/cmTC_0475b.dir/testCXXCompiler.cxx.o  -o cmTC_0475b   && :
/snap/flutter/current/usr/lib/x86_64-linux-gnu/libgcrypt.so: undefined reference to `gpgrt_get_syscall_clamp@GPG_ERROR_1.0'
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:2 (project)    
Farina answered 5/5, 2021 at 6:23 Comment(0)
B
5

In Linux Mint 20.2 Cinnamon with Flutter 2.5.2 and snap 2.51.7 I fixed by doing

sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev
flutter clean
flutter run -d linux
Bathrobe answered 4/10, 2021 at 2:15 Comment(0)
F
3

There is an issue with snap version of Flutter (https://snapcraft.io/flutter) April 15th 2021 release.

The solution is to do a manual install (https://flutter.dev/docs/get-started/install/linux#install-flutter-manually)

Farina answered 5/5, 2021 at 14:2 Comment(1)
It's now Sep 2023 and I still have a similar issue which can be resolved by manually installing Flutter.Wow
B
1

I had the same issue on ubuntu 22.04 use the flutter documentation for building and releasing linux app and install snapcraft here https://docs.flutter.dev/deployment/linux

Burge answered 12/5, 2022 at 9:48 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Ronaronal
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewComras
N
0

I reinstalled my mint and installed flutter manually and got the same issue

Nilsson answered 3/10, 2023 at 1:29 Comment(1)
found solution here #72419145Nilsson
A
0

According to the link error log, the problem is a link to the libgcrypt cryptographic library, and the missing reference to the gpg-error library causes an undefined symbol error.

You can try the following ways to solve:

Make sure the gpg-error library is installed:

sudo apt install libgpg-error-dev

In the CMake compilation script, find the libgcrypt library reference and add the gpg-error library:

target_link_libraries(your_target libgcrypt libgpg-error)

If the flags are obtained through pgg-config, you can set them to:

pkg_check_modules(LIBGCRYPT libgcrypt libgpg-error)

After clearing CMake cache, the configuration is generated again and the reference sequence is correct. If you are using the name version (libgcrypt.so.x) link, link to the libgcrypt.so library without the version instead. Update the libgcrypt library to the latest version. Essentially, you need to ensure that a reference to the gpg-error library is included when compiling and linking to resolve undefined symbol errors.

Accordion answered 18/10, 2023 at 7:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.