[Solved] GCC cannot use include paths provided by pkg-config

I have Haiku B4 installed in VirtualBox 7.x for porting purposes of some of my projects to Haiku.

I have dependencies like freetype2 installed, using the ‘freetype’ and ‘freetype_devel’ packages, and confirmed the header files are in place. In the Makefile for my project I use pkg-config to get the include paths for freetype2 and other dependencies, just like on Linux/BSD/Windows/etc.

The paths I get from pkg-config take the form ‘-I/packages/freetype-/.self/develop/headers/freetype2’, which I can access in the terminal, even though these are in HPKG archives from what I can tell.

Yet it seems that GCC cannot access these paths, as I get ‘ignoring nonexistent directory’ for every single path provided by pgk-config.

Why is pkg-config (the standard & the newer one from the repository) returning paths that cannot be used by GCC?

Do you happen to use 32 bit Haiku?

No, I’m using the 64-bit version.

Tried with: -I/system/develop/headers/freetype2 ?

I imagine that’ll work, but I’m trying to avoid hardcoding paths for specific platforms, ergo the use of pkg-config.

This seems strange, these paths should be perfectly normal files from GCC point of view. They indeed come from hpkg files but they are exposed as regular files by packagefs.

I guess, to debug this, we’ll need an strace of gcc when it is trying to load these files, and try to understand why it decided that the directories are “nonexistent”. They shouldn’t be.

The interesting thing is that for sdl2-config --cflags I get as path -I /boot/system/develop/headers/SDL2, so that’s not very consistent.

As for why the other path fails… it appears the versioning is at fault: in the path I have e.g. /packages/freetype-2.12.1-3/.self/develop/headers/freetype2 yet from pkg-config I get as freetype version 2.12.1-4. The same is the case for the graphite2 package, where the version provided by pkg-config also is one patch-level (-2 vs -1) ahead of what is installed.

It appears pkg-config is using faulty data here…

All right, seems that the cause was that I had for these packages the newer _devel package and the older runtime package. That’s why I got the error, as pkg-config took the version from the _devel package.

After a pkgman update it all seems to be resolved.

3 Likes

This case is supposed to be prevented by having _devel packages depend on exactly the same version of the base package. So I wonder how it went wrong in your case? Perhaps there were updates pending and a reboot was needed?

Good question… I did not perform any update actions with pkgman after installing Haiku B4 x64 in VirtualBox, and installed these packages simultaneously using a shell script, so it should have used whatever package information it had at hand. The graphite2 dependency is also a sub-dependency of the ones I requested, which makes it even more… interesting.

I have a fresh VM set up with a nightly ISO (for UDP socket functionality with the software I’m porting), so I’ll keep an eye out for whether it happens there too.

2 Likes

Ran through the same shell script on the nightly ISO (downloaded yesterday), and I did not have the same issue with the runtime & _devel packages, so that might have been a one-off thing.

I did however run into an issue with the GLIBC version, as after compiling the application, I could not run it until a newer version of libstdc++ was installed. Here again a pkgman update fixed things.

Still don’t seem to have functioning (IPv6) UDP sockets in this nightly, but that’s another topic for another thread.