class Demo.HelloWorld : GLib.Object {
public static int main(string[] args) {
stdout.printf("Hello, World\n");
return 0;
}
}
Command:
$ valac sample.vala
I get this error:
Package gobject-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gobject-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gobject-2.0' found
error: pkg-config exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
I tried different ways like --pkg and etc but nothing worked.
When I try to get list of known packages by pkg-config, it returns nothing.
$ pkg-config --list-all
I searched in the internet and forum but nothing found to fix my problem. I’m pretty sure I missed something in my local system.
Some packages have multiple outputs and you will need to use the correct one. gobject-2.0.pc is in glib.dev instead of just glib.
I’ve found nix-index with its nix-locate tool to be invaluable for this kind of stuff. It finds exactly which derivation produces certain files in its output. Since updating the index takes forever, I also recommend using nix-index-database which does this nicely with the regular system updates.
In your case, it would produce:
$ nix-locate gobject-2.0.pc
(virtualgl.out) 365 r /nix/store/kn0wlcvwkgxlzssxgyy6am453dwmf2ik-glib-2.78.1-dev/lib/pkgconfig/gobject-2.0.pc
vlang.out 304 r /nix/store/rhk41k4mxy2q2q3nqpfzf4n5rg96hpf5-vlang-0.4.3/lib/vlib/v/pkgconfig/test_samples/gobject-2.0.pc
remarkable-toolchain.out 287 r /nix/store/jm8lh0xlyj1lqghd5hd8y4ih39ynizla-remarkable-toolchain-3.1.2/sysroots/cortexa9hf-neon-remarkable-linux-gnueabi/usr/lib/pkgconfig/gobject-2.0.pc
remarkable2-toolchain.out 287 r /nix/store/v8id91gp55sz64vnwg0q1lv281hc5271-remarkable2-toolchain-3.1.2/sysroots/cortexa7hf-neon-remarkable-linux-gnueabi/usr/lib/pkgconfig/gobject-2.0.pc
glib.dev 365 r /nix/store/xc5casr35bpf24dj0sp3jjwh76mkslg4-glib-2.78.1-dev/lib/pkgconfig/gobject-2.0.pc
What is the value of your PKG_CONFIG_PATH environment variable? On my system, it’s empty. I needed to add the installed location of those libraries before pkg-config --list-all would produce anything.