Potential systemLibrary pkgConfig issue


#1

Hello there. I'm having a bit of a weird issue when trying to build a project with a dependency on a C systemLibrary.

In my Package.swift I have the following line in the targets section:
.systemLibrary(name: "Cwlroots", pkgConfig: "wlroots"),

Everything seems to be set up correctly, but when I run swift build, I get an error stating that pixman.h cannot be found in a C-header file.

Running pkg-config --cflags wlroots yields:
-I/usr/include/libdrm -I/usr/include/pixman-1.

If I run swift build with the flag -Xcc -I/usr/include/pixman-1, the package builds successfully.

I'm unsure whether this is an issue with my configuration, or if this is a bug with the package manager.
Please let me know if I can provide any more information that would be helpful.

Thanks :slight_smile:


(David Hart) #2

Is the project available online? If not, can you check if SwiftPM inserted the correct flags in the .build/debug.yaml file?


#3

I checked the debug.yaml file and no -I flags are present.


(Cory Benfield) #4

What system are you building on, Linux or Apple?

SwiftPM does not actually use the pkg-config command line tool, instead it uses its own pkg-config parser. That means it may have trouble locating your .pc files, most commonly on Apple platforms.


#5

I'm building on Linux. It seems that SwiftPM is able to locate the .pc files because it will throw an error if the pkgConfig string is invalid, e.g. if I change it to wlroot instead of wlroots.


(David Hart) #6

Can you open a ticket on bugs.swift.org with a reproducible case? Either your project, or a small test case?