Static linking on Windows
I've had static linking work out of the box on Linux, Android and macOS, but even with all the recent Windows love, it's still not easy to get it working.
The main issue seems to be that when linking dynamically, __declspec(dllimport)
is used which adds an __imp__
prefix to symbols, but when linking statically the regular symbols are used. Cerbero outputs both shared and static library files by default, but the static ones still incorrectly link against each other using the dynamic symbols, so when statically linking everything together in your own project, they don't resolve because only the static symbols are present.
I am currently working around this by forcing the meson build type to static, and making sure GST_STATIC_COMPILATION
and ORC_STATIC_COMPILATION
are defined. This prevents tests and tools from linking properly. Here is my patch on top of 1.17.2 for example: https://github.com/viviedu/cerbero/commit/8482f2a72612a4603c0bcd733ea53acdf2e268a9
Is there already a better way to do this? I'm not sure if there even is a perfect fix, since you could theoretically mix and match static and dynamic linking in your own project however you want. Should there at least be a build time option (variant?) in Cerbero for it?