FS#6295 - build failure on Mac OSX 10.9 and 10.10

Attached to Project: OpenTTD
Opened by ad (dunn) - Monday, 04 May 2015, 00:14 GMT
Last edited by Michael Lutz (michi_cc) - Sunday, 08 January 2017, 21:29 GMT
Type Bug
Category Build system
Status Closed
Assigned To No-one
Operating System Mac OS X
Severity Medium
Priority Normal
Reported Version 1.5.0
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


Initially reported on SO (, there's a section in config.lib that's preventing OpenTTD from building on recent versions of OSX. It's adding flags that cause linker errors; here's what the build logs look like:

Attached is a patch that's been used by MacPorts as well as Homebrew for a while without problems.
This task depends upon

Closed by  Michael Lutz (michi_cc)
Sunday, 08 January 2017, 21:29 GMT
Reason for closing:  Implemented
Additional comments about closing:  In r27727.
Comment by Alberth (Alberth) - Monday, 04 May 2015, 08:34 GMT
Assuming that code was added for a reason, your patch will break building at whatever system uses those settings.
That is not acceptable.

Rather than causing havoc at other systems by deleting crucial settings, your patch should add checks that prevents adding bad settings for systems like yours.
Comment by frosch (frosch) - Monday, 04 May 2015, 15:58 GMT
The part of config.lib looks like it is meant for GCC. The link to github shows a log with clang.
Likely config.lib should check for GCC here.
Comment by ad (dunn) - Tuesday, 05 May 2015, 22:31 GMT
The build fails with GCC as well as with Clang.
Comment by andythenorth (andythenorth) - Wednesday, 16 September 2015, 19:01 GMT
This may not help, but posting for the record. I have been able to build trunk OpenTTD on multiple versions of Mavericks and Yosemite, using default clang as provided by Apple, as per

For Yosemite, I didn't need to update any ports or other packages (although my system does have a macports trees that was installed under Mavericks, which may still be supplying some packages).
Comment by Clemens Lang (neverpanic) - Tuesday, 08 November 2016, 22:41 GMT
Just for the record, the issue here is that clang++ will use libc++ as standard library by default if you do not compile with a deployment target (the -mmacosx-version-min flag in config.lib) older than when Apple switched the default to libc++. You get the linker error about missing std::string symbols when you try to link a piece of code compiled against libc++ with libstdc++ or vice versa. The linker error occurs, because symbol mangling for std::string differs (on purpose) between these standard library implementations. If you didn't get the linker error, you'd instead see crashes at runtime.

The patch posted here was originally written by me ( and later tagged with "Upstream-Status: Inappropriate [configuration]". MacPorts has a policy of always building against the host system, not against one of the OS X SDKs like the binaries built by OpenTTD are. It is probably not appropriate to be merged here.

I did not investigate what the issue with the 10.5 minimum version is, since the code was inappropriate for MacPorts' guidelines anyway. My best guess would be that the compiler uses libstdc++ (due to -mmacosx-version-min 10.5) but the linker uses libc++ (because LDFLAGS doesn't contain a deployment target). Note that forcing a deployment target that makes the compiler use libstdc++ also requires you to build any C++ dependencies with the same setting (which is also why I removed it for MacPorts).

Feel free to reach out to if you need help figuring out this C++ standard library mess on OS X.
Comment by andythenorth (andythenorth) - Tuesday, 27 December 2016, 21:47 GMT
Clemens thanks this isn't being ignored :) I don't have an El Capitan or Sierra system to hand right now to test compiles (I'm also not the right person to figure out compile issues - way out of my depth).
Comment by andythenorth (andythenorth) - Sunday, 08 January 2017, 19:56 GMT