Problem building gdk-pixbuf with MSVC

Many years ago I used to build gdk-pixbuf and I’ve just needed to return to it (except using more up-to-date code).

Back in the good old days, it was possible to build as a DLL (using MSVC) simply through having _MSC_VER defined (which in turn defined _GDK_PIXBUF_EXTERN). Admittedly the version of gdk-pixbuf here looks like it’s a cut-down version but the above defines don’t seem to exist any more (and therefore nothing gets exported when building as a DLL).

Whoever cut the version down, have they maybe cut out too much? Or is some other mechanism used these days? Or is gdk-pixbuf just not buildable as a DLL any more? (not using MSVC anyway…)

Thanks for any advice!

A bit more info…

I’ve searched the source files here and there’s no mention of _MSC_VER at all any more. Does that mean that MSVC builds aren’t supported these days?

I might have got this the wrong way around :blush:

I just looked back at the code when I used to build gdk-pixbuf and it looks like it was then at version 2.40.0

But the code I’m building now (which I just assumed would be newer) might in fact be older. Its config.h file seems to suggest version 2.31.1

So might that be the problem - i.e. the “newer” code actually dates back to a time before MSVC support got added?

The config.h file is autogenerated by the build system, so if you have a stale config.h in your build directory you should remove it.

Thanks @ebassi - in that case, do you happen to know the current status of MSVC support? It was mostly the inclusion of __declspec() which allowed gdk-pixbuf stuff to get exported or imported from a DLL. Has it been removed in the newer versions?

No, gdk-pixbuf still works perfectly fine with MSVC: we test it as part of GTK’s CI pipeline, and just to be on the safe side, I just added a CI job to gdk-pixbuf itself for MSVC builds.

Of course, we only test the gdk-pixbuf build system: if you are not using Meson, then you’re entirely on your own.

That makes sense @ebassi. I suspect that the “new” code I’m trying to build is in fact very old code.

I’ve looked at the two versions in a differ and there’s very little difference between them. All the __declspec() stuff is absent and some comments are different but the actual code is essentially the same.

Gvsbuild also has support for building gdk-pixbuf on Windows: GitHub - wingtk/gvsbuild: GTK stack for Windows · GitHub.

Good to know @danyeaw - many thanks :+1: