Building Flutter Linux on Manjaro

Photo by Danist Soh on Unsplash

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

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)

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

Which resulted in:

[        ] -- Checking for module 'gtk+-3.0'
[   +1 ms] --   No package 'gtk+-3.0' found

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

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

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

Let's add this directory to PKG_CONFIG_PATH environment variable:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig

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!

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

pkg-config --libs shared-mime-info

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!

Did you find this article valuable?

Support codeblend by becoming a sponsor. Any amount is appreciated!