[LV2] Building plugin binaries for older macOS versions

Robin Gareus robin at gareus.org
Sun May 27 06:51:49 PDT 2018


On 05/27/2018 03:09 PM, Stefan Westerfeld wrote:
>    Hi!
> 
> I'm currently trying to build a self-contained, statically linked SpectMorph
> for macOS. My first goal is providing a VST plugin binary, but since the
> situation is similar for LV2, I hope this is not terribly off-topic.

The build-system is not only similar, but pretty much identical.

> My development system is running macOS 10.13, and so far, I've used the command
> line tools for building the binary. For the dependencies, such as cairo, I've
> used brew, and linked against the /usr/local/lib/cairo.a and so on. I tested
> the plugin on my development machine, and it seems to work fine.
> 
> The question I have is: what do I need to do if I want to build a version of
> the plugin that will also run on older macOS versions?
> 
> I tried to google this, but I still don't understand it fully.
> - Is a plugin built in this way compatible with older macOS versions?
> - If not, should I somehow build the binaries using older command line tools?
> - Or build with an older Xcode version?
> - Or build with an older macOS SDK?
> - Can I combine any SDK with the newest command line tools / Xcode?
> - Will static linking ensure that my plugin binary will run on a macOS with
>   an older stdc++ library?

Generally speaking just an old SDK will be sufficient. For plain C you
can use recent x-code with older SDKs, but C++ will be a problem (modern
xcode only works with libc++).


Regarding static linking, check that you also include indirect
dependencies (e.g. pixman, libpng, zlib) and don't expose any symbols of
those libraries (-fvisibility=hidden) because OSX/macOS has a flat
namespace.

I found homebrew to be unsuitable to produce any re-distributable
binaries. I'm also not sure if homebrew produces multi-arch libraries.
If you want to target older OSX versions you'll likely also want 32bit
support (perhaps even universal binaries with PPC support, too).


I do built plugins (all plain C) on a 10.6 system with apple's gcc-4.2.
The resulting multi-arch binaries does work on 10.5 and later.


For ZynFusion, which needs C++11, I took another approach: Compile gcc-6
on 10.6, then compile each architecture separately and combine the
result (lipo).

The build-system can be found at
https://github.com/zynaddsubfx/zyn-build-osx and produces MacVST and
LV2, 32 and 64bit intel. It may be good for inspiration

..and also showcases the C/C++ Flags to hide symbols in static libs:
https://github.com/zynaddsubfx/zyn-build-osx/blob/master/01_compile.sh#L135-L137

HTH,
robin

PS. The build-scripts run a normal user, no admin rights needed. I
usually create some throwaway build account, that ignores all system
customization (e.g. /usr/local, /opt, homebrew etc) and is confined to
the build-user.  That way you can also test later if it works for
another user.


PPS. If you're not worried about legal issue, you could try to
cross-compile: https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple






More information about the Devel mailing list