Building Flutter Linux on Manjaro

tobhai

Tobias Haindl

Posted on August 6, 2022

Building Flutter Linux on Manjaro

Last week I was eager to check out a little Flutter application built by Lucas Schuster.

I was especially interested in trying the Flutter Desktop support for Linux.

After installing Flutter via fvm, I checked out his Git repository and issued the following command for building the Flutter app on Linux:

flutter build linux
Enter fullscreen mode Exit fullscreen mode

Unfortunately this gave me the following error message:

CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:605 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPkgConfig.cmake:827 (_pkg_check_modules_internal)
flutter/CMakeLists.txt:25 (pkg_check_modules)
Enter fullscreen mode Exit fullscreen mode

I doubled checked the official documentation and verified that the following packages were installed:

  • clang
  • cmake
  • ninja-build
  • pkg-config
  • gtk3

Afterwards I reran the build command but with the verbose flag enabled:

flutter build linux -v
Enter fullscreen mode Exit fullscreen mode

Which resulted in:

[] -- Checking for module 'gtk+-3.0'
[+1 ms] -- No package 'gtk+-3.0' found
Enter fullscreen mode Exit fullscreen mode

Flutter was not able to locate my gtk installation.

You can check if pkg-config can locate the package by running:

pkg-config --libs gtk+-3.0
Enter fullscreen mode Exit fullscreen mode

This command returned the following error on my system:

Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-3.0' found
Enter fullscreen mode Exit fullscreen mode

I fixed this by figuring out where gtk3 is installed and adding the directory to the PKG_CONFIG_PATH variable.

Check where the package is located:

pacman -Ql gtk3

gtk3 /usr/lib/pkgconfig/gtk+-3.0.pc
Enter fullscreen mode Exit fullscreen mode

Let's add this directory to PKG_CONFIG_PATH environment variable:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig
Enter fullscreen mode Exit fullscreen mode

You might want to add this to your .bashrc or .zshrc config file.

Don't forget to reload your environment, e.g. with the source ~/.zshrc!

After modifying the PKG_CONFIG_PATH the Flutter build returned:

Package 'shared-mime-info', required by 'gdk-pixbuf-2.0', not found
Configuring incomplete, errors occurred!
Enter fullscreen mode Exit fullscreen mode

Okay, another familiar error, let's check if shared-mime-info is available:

pkg-config --libs shared-mime-info
Enter fullscreen mode Exit fullscreen mode

If the package was not found on your system, you can install it via yay or pacman

E.g.:yay -Sy shared-mime-info

Afterwards check the installation path:yay -Ql shared-mime-info

Search for the directory including the shared-mime-info.pc file, in my case it was: /usr/share/pkgconfig/

Therefore, I added this directory to the PKG_CONFIG_PATH as well:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig/:/usr/share/pkgconfig/

Afterwards I was able to build and run the Flutter application on Manjaro!

Photo by Danist Soh on Unsplash

💖 💪 🙅 🚩
tobhai
Tobias Haindl

Posted on August 6, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Building Flutter Linux on Manjaro
flutter Building Flutter Linux on Manjaro

August 6, 2022