Hello,
I'm packaging wxWidgets and wxPython for a package manager on macOS.
TL;DR: how do I properly set CPPFLAGS/CXXFLAGS and LDFLAGS when
installing wxPython?
Long version below:
Recently we got an interesting bug report:
https://trac.macports.org/ticket/53040
Let me explain the background.
OS X < 10.9 doesn't support C++11 by default, but when installing the
package manager, users are able to choose libc++ as their default
stdlib which supports C++11. Due to an increasing amount of software
nowadays requiring C++11, more users are expected to do that
wxWidgets builds without any issues. I only have to set
CPPFLAGS="-stdlib=libc++"
and additionally
LDFLAGS="-stdlib=libc++"
(Usually software would only require the first one to be set,
wxWidgets requires both, but that's fine.)
The problem appears when building wxPython. I build wxPython with
setup.py WX_CONFIG=/path/to/wx-config
so that only the Python support is built on top of the exiting wxWidgets.
I additionally replace WXPORT in config.py from 'osx_carbon' to
'osx_cocoa' (not that it should matter in any way).
Now, wx-config would tell me exactly which compiler it was built with:
$ wx-config --cc
/usr/bin/clang
$ wx-config --cxx
/usr/bin/clang++
but I don't find any way to "recover" the "-stdlib=libc++" flag. None of
$ wx-config --libs
$ wx-config --cflags
$ wx-config --cxxlags
$ wx-config --cpplags
would tell me the stdlib.
I can fix the situation in any of the following ways:
(a) patch wxWidgets in such a way that
wx-config --[one-of-those-flags]
would also return me -stdlib=libc++
(b) patch setup.py in wxPython with:
cflags.append('-stdlib=libc++')
lflags.append('-stdlib=libc++')
(c) provide those flags in environment or as arguments of setup.py
I would prefer (a), but would like to avoid (b) if possible.
But I would prefer to get the official answer (and perhaps ask for an
official patch).
Thank you,
Mojca