Search code examples
windowsvalapkg-configmsys2

Vala examples compile errors


Installed Vala for Windows64 from the MSYS2 project. Started running various examples from https://wiki.gnome.org/Projects/Vala/Examples. Some examples produce errors like

... the "Clutter Samples:Animated Actors"

D:\Projects\Vala\Examples>valac.exe --version
Vala 0.36.1-dirty

D:\Projects\Vala\Examples>valac.exe --pkg clutter-1.0 clutter.vala -o clutter.exe
D:/Projects/Vala/Examples/clutter.vala.c:7:29: fatal error: clutter/clutter.h: No such file or direc
tory
 #include <clutter/clutter.h>
                             ^
compilation terminated.
error: cc exited with status 1
Compilation failed: 1 error(s), 0 warning(s)

... and the "Vala GTK+ 3.x Examples: Basic Sample"

D:\Projects\Vala\Examples>valac.exe --version
Vala 0.36.1-dirty

D:\Projects\Vala\Examples>valac.exe --pkg gtk+-3.0 gtk+3-hello.vala -o gtk+3-hello.exe
D:/Projects/Vala/Examples/gtk+3-hello.vala.c:17:21: fatal error: gtk/gtk.h: No such file or director
y

                     ^
compilation terminated.
error: cc exited with status 1
Compilation failed: 1 error(s), 0 warning(s)

...and the Vala Collections: libgee sample

D:\Projects\Vala\Examples>valac.exe --version
Vala 0.36.1-dirty

D:\Projects\Vala\Examples>valac.exe --pkg=gee-0.8 libgee-collections.vala -o libgee-collections.exe

error: Package `gee-0.8' not found in specified Vala API directories or GObject-Introspection GIR di
rectories
Compilation failed: 1 error(s), 0 warning(s)

I realize pkg:gee-0.8 is not installed, but I did find 0.20.0-1 using pacman. I dont know how to reference this library?

$ pacman -Ss gee -v
Root      : /
Conf File : /etc/pacman.conf
DB Path   : /var/lib/pacman/
Cache Dirs: /var/cache/pacman/pkg/
Hook Dirs : /usr/share/libalpm/hooks/  /etc/pacman.d/hooks/
Lock File : /var/lib/pacman/db.lck
Log File  : /var/log/pacman.log
GPG Dir   : /etc/pacman.d/gnupg/
Targets   : gee
mingw32/mingw-w64-i686-libgee 0.20.0-1
    A collection library providing GObject-based interfaces and classes for
    commonly used data structures (mingw-w64)
mingw64/mingw-w64-x86_64-libgee 0.20.0-1
    A collection library providing GObject-based interfaces and classes for
    commonly used data structures (mingw-w64)

Obviously my installation is incorrect/incomplete. What do I need to change or install to fix these type of issues?

Thanks for your help!


Solution

  • Running valac.exe directly can be a problem.

    Usually when using msys2 to compile something you first enter the msys2 shell with the MSYSTEM environment variable set up correctly. (there are scripts and in newer versions executables in the msys2 root folder that can do that for you).

    For example when you set MSYSTEM=MINGW64 (caveat: MINGW64 must be upper case!) and then run mingtty.exe or bash.exe --login you can then check your PKG_CONFIG_PATH var:

    $ echo $PKG_CONFIG_PATH
    /mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
    

    Be sure to understand the difference of the three MSYSTEM settings:

    • MSYS - Only used to bootstrap the core msys2 system and for packaging purposes
    • MINGW32 / MINGW64 - The "normal" environment (32-Bit / 64-Bit) you work in when using msys2.

    The pacman package names for the different MSYSTEM environment have prefixes. I.e. the packages that start with mingw-w64-x86_64 are used in the MSYSTEM=MINGW64 environment.

    vala uses pkg-config (be sure to have mingw64/mingw-w64-x86_64-pkg-config installed) when you specify something with --pkg and pkg-config then searches for .pc files (like gee-0.8.pc).

    The mingw-w64-x86_64-libgee package installs its pc file as /mingw64/lib/pkgconfig/gee-0.8.pc.