Include path of systemLibrary on Windows without pkg-config?

Hey there,

I made a Swift app using GLFW and Skia (the Google vector graphics library). I am using the mono fork of Skia for C bindings.

On Linux it works fine, I am able to include and link against Skia by using this line:

.systemLibrary(name: "Skia", path: "External/Skia", pkgConfig:"skia")

In External/Skia, I have a modulemap:

module Skia {
    umbrella header "skia.h"
}

And skia.h:

#include <skia/include/c/gr_context.h>
#include <skia/include/c/sk_types.h>
#include <skia/include/c/sk_canvas.h>
#include <skia/include/c/sk_surface.h>
#include <skia/include/c/sk_colorspace.h>
#include <skia/include/c/sk_paint.h>
#include <skia/include/c/sk_image.h>
#include <skia/include/c/sk_bitmap.h>
#include <skia/include/c/sk_pixmap.h>

Don't question why it has /include in the path, it's part of the Skia Experience :tm: .

Now that I am trying to port this to Windows (MSVC, using Powershell), I am struggling with SwiftPM to have it "see" my Skia build. Windows does not have pkg-config and I don't see a way to specify an include path in systemLibrary, so how can I do it? I will have the same issue with GLFW, and GL, and any other system library that I need. I will also need to give it the path to skia.lib for linking.

Do I really need to install pkg-config and its glibc friend, or is there a way for me to circumvent that? Should I use something like MSYS2 instead?

Thanks in advance!

AFAIK until SwiftPM gains special support for any kind of automated header search on Windows, you'll have to manually pass header search paths to swift build invocations. Not sure if SwiftPM even supports pkg-config on Windows in any way. @compnerd please correct me if I'm wrong.

1 Like

The reason that there is an include in the path is because you are trying to use the headers from the source tree rather than an install tree. The structure of the source tree is not meant to match the install tree. You should consider using an installed image rather than the source tree to ensure that you are not accessing private headers.

pkg-config is only used to find the paths to the installation, it isn't needed for any other purpose. You can easily pass the appropriate header search paths and library search paths (along with any necessary options) manually. The header search path can be augmented via -I and the library search path via -L. Any other flags for the C compiler driver should be passed via -Xcc.

This is correct - pkg-config is not an expected tool on Windows. In theory, yes, it could be made to work, all it does is searches for a known location - PKG_CONFIG_PATH - for files that are named [package].pc and reads the key-value contents (it is just an .ini files IIRC). There is nothing platform specific to it. However, as I have stated previously, it would be better to support nuget or vcpkg compared to pkg-config due to the alternate tools being more common on the platform.

2 Likes

There is no such thing as an "installed image" for Skia, this is what I meant by the "Skia Experience". There is no make install, and the whole library is made like that: skia/sk_colortable.h at xamarin-mobile-bindings · mono/skia · GitHub

But anyway, passing the flags manually work for the time being, thanks for your answers!

I’ve opened SR-15357 to track the support of vcpkg. Will look into it once I’ve got the time.

1 Like
Terms of Service

Privacy Policy

Cookie Policy