c++ library usage
Michael Dickens
michaelld at macports.org
Wed Jun 21 01:48:18 UTC 2017
Hi MP devs - A hopefully brief discussion of / query about c++ library
usage, with a little background. What I describe below works for me,
which makes me wonder if what I'm doing is nonstandard use of 'port' or
what's going on ...
GNU Radio devs were asked whether GR compiles using GCC7 cleanly, so I
decided to give it a try on my macOS setup (10.12 most recent of
everything running on a MacBook Pro Retina Touchpad; standard MacPorts
install from GIT). Installing GCC7 was pretty simple, but of course GR
didn't link because some of its dependencies were not built using
libstdc++ from libgcc-devel, so the C++ library wasn't correct & mixing
C++ libraries doesn't generally work anyway.
Adding some temporary code to the Portfiles of those dependencies
allowed me to install them with compiler variants, which did the trick &
GR built cleanly & even passes "make test". The dependencies also work,
even though they are linked to libgcc-devel's libstdc++; they do not use
libc++ -- directly or indirectly from the look of it. Thus, I was able
to pretty quickly report back that GR is, or will be shortly when I get
some pull requests in place, compatible with GCC7. There are plenty of
deprecation warnings, but we can ignore those for now.
The above got me thinking about c++ library linking and usage, because
this isn't the first time I've run into this issue: I want to install a
port using clang4.0 or GCC7 & then need to go through & rebuild specific
dependencies using the same compiler / c++ library. Seems like in 'port'
we could provide information as to whether the port uses c++, and if so
keep information as to which c++ library was used for linking (e.g.):
xcode libc++, xcode libstdc++, MacPorts libc++, MacPorts libstdc++.
Then, when someone does something "stupid" like what I try to do way too
often, port can tell them so & ask if they really want to go through
with this & then offer to rebuild the c++ dependencies using the desired
compiler. It seems like offering compiler variants, while useful for
testing, isn't the most practical except on specific ports (e.g.: atlas,
scipy, numpy, openblas, octave, arpack, itsol, qrupdate). GR requires
just 5 dependent ports to be rebuilt (boost, cppunit, log4cpp, scipy,
uhd).
This also got me wondering why libc++ is required for macOS 10.12, or
maybe that I'm missing something in the way libstdc++ (via libgcc-devel)
is built or used? If I can successfully install and use libstdc++ as the
primary linked-to c++ library, then is it a legit way to install
c++-based projects? is this maybe just libgcc-devel, not libgcc? Am I
just missing something?
Thanks for your thoughts & opinions. - MLD
More information about the macports-dev
mailing list