libepoxy icon indicating copy to clipboard operation
libepoxy copied to clipboard

Fix inconsistent linkage when building as static on Windows

Open haileys opened this issue 2 years ago • 1 comments

EPOXY_PUBLIC is defined to __declspec(dllexport) extern in meson.build only if building as a shared library on Windows. Otherwise it's defined to extern if building as a shared library, and if building as static, it is not defined at all.

However, when EPOXY_PUBLIC is not defined, epoxy/common.h will define EPOXY_PUBLIC to __declspec(dllimport) extern if building on MSVC.

I'm not exactly sure what's going on with the duplicated definition here, but I have worked around the problem by defining EPOXY_SHARED if building as a shared library. This define is set in common_cflags, which means it will be propagated through to pkgconfig, so consuming libraries will set this variable appropriately. Then I have changed common.h to only define EPOXY_PUBLIC for dll imports if EPOXY_SHARED is also set.

haileys avatar Jan 20 '24 01:01 haileys

Thanks! I'll review this MR soon once I can properly test it.

ebassi avatar Jan 24 '24 14:01 ebassi