Re: ld: error: unable to find library -lstdc++

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Fri, 03 Mar 2023 15:20:46 UTC
Odhiambo Washington <odhiambo@gmail.com> writes:

> Hi,
> FreeBSD-13.1-RELEASE here.
>
> I am installing Xapian within a virtual environment and I am getting stuck
>
> It might help to mention that I am using the script at:
> https://github.com/notanumber/xapian-haystack/blob/master/install_xapian.sh

-lstdc++ is part of lang/gcc* but FreeBSD >= 10 ships Clang with -lc++ instead.
C++ compiler automatically adds -lstdc++ or -lc++ unless -nostdlib or -nostdlib++.
Modern Clang converts -lstdc++ into -lc++ unless -nostdlib or -nostdlib++.
xapian-bindings uses libtool which adds -nostdlib and uses autoconf to detect
GCC which includes Clang due to __GNUC__ defined for compatibility.

Why not use ports/packages where this is already solved?

From databases/py-xapian/Makefile
  post-patch:
  	@${REINPLACE_CMD} -e 's|-lstdc++||g' ${WRKSRC}/configure

Alternatively, replace -lstdc++ with -lc++ in Clang via environ(7)

  $ export CCC_OVERRIDE_OPTIONS='# s/stdc\+\+/c++/' # sh(1) style
  $ setenv CCC_OVERRIDE_OPTIONS '# s/stdc\+\+/c++/' # csh(1) style