[cairo] [MSVC] Link Error when building Static Libraries using Meson

Tim-Philipp Müller t.i.m at zen.co.uk
Wed Feb 24 16:27:57 UTC 2021


On Tue, 2021-02-23 at 15:30 +0530, Naveen M K wrote:

Hi Naveen,

> I tried building Cairo statically on MSVC 2019. I got some link
> errors.
>
> (snip)
> csi-replay.c.obj : error LNK2019: unresolved external symbol
> __imp_cairo_create
> (snip)

I haven't tested static meson builds on Windows with MSVC, so I'm just
guessing here but I suspect it's related to the cairo_public __declspec
import/export defines.

I believe these linker errors with __imp_* happen when the app gets
built with symbols imported via __declspec(dllimport), i.e. in
expectation of an import lib for the dynamic library, but you're not
actually doing dynamic linking then.

It might just work if you configure meson with

  -DCAIRO_WIN32_STATIC_BUILD

as additional CFLAGS/c_args, and you will need to set this when you
build your own app later too then.

We might be able to handle this case better automatically in Cairo's
meson build, so would be great if you could file an issue in gitlab
about it at

  https://gitlab.freedesktop.org/cairo/cairo

Thanks!

Cheers
 Tim



More information about the cairo mailing list