Pass “-stdlib=libc++” to c++ linker with autotools
-
24-05-2021 - |
Question
I'm trying to compile ImageMagick (in particular Magick++) with clang++ and libc++. Therefore I need to pass -stdlib=libc++ to both compiler and linker.
While CXXFLAGS="-stdlib=libc++" works fine for compiling, LDFLAGS="-stdlib=libc++" seems to only affect the C linker.
How to correctly tell ./configure or make to use this flag when linking C++ libraries?
Solution
Use both — CXXFLAGS for the C++ compiler and LDFLAGS for the linker:
./configure CXXFLAGS="-O2 -g -stdlib=libc++" LDFLAGS="-stdlib=libc++"
OTHER TIPS
You could try:
LDFLAGS="-Wl,-stdlib=libc++"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow