linking problems

Ryan Schmidt ryandesign at
Mon Dec 9 05:17:47 UTC 2019

On Dec 8, 2019, at 18:32, Werner LEMBERG wrote:
> On my Mac Lion box running an up-to-date MacPorts, for experimentation
> reasons I try to build the current git version of lilypond directly
> from the repository – this is, I use the MacPorts infrastructure for
> compilation with a recent clang version, but without any adaptations
> of lilypond's source code.
> Building in a separate directory I configure with
>  /path/to/lilypond/git/configure \
>  CC=clang-mp-9.0 \
>  CXX=clang-mp-9.0 \
>  --prefix=... \
>  --with-texgyre-dir="/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/tex-gyre" \
>  --with-flexlexer-dir="/opt/local/include" \
>  --disable-documentation \
>  --disable-optimising
> then calling `make`.  However, this fails at the linking stage; I get
> zillion of messages like
>  Undefined symbols for architecture x86_64:
>    "std::__1::basic_string
>      <char,
>       std::__1::char_traits<char>,
>       std::__1::allocator<char> >::copy
>         (char*,
>          unsigned long,
>          unsigned long) const", referenced from:
>      ly_format(scm_unused_struct*, scm_unused_struct*)
>        in general-scheme.o
> I guess I miss some linker flags due to the need of a special C++
> library.
> * Which linker flags do I miss?
> * Why doesn't the above invocation of the `configure` script
>  automatically handle this?  Or to ask differently, why doesn't
>  `clang-mp-9.0` find its own library files automatically (at least I
>  presume this is the problem)?

Since MacPorts 2.6.0 we switched to libc++ as our default c++ stdlib.

If you use Xcode clang or an older MacPorts clang, it doesn't know about that, so you have to tell it by putting "-stdlib=libc++" in CXXFLAGS. Depending on the build system, you may also need to put it in LDFLAGS or make other adjustments to get the flags passed in to every command that needs it.

If you use a recent MacPorts clang compiler, it should automatically use libc++.

Probably the problem is that you have specified CXX=clang-mp-9.0 -- that's a C compiler. You want the C++ compiler here: CXX=clang++-mp-9.0

More information about the macports-users mailing list