I have recently upgraded my Clang compiler on my M1 Mini Mac from Clang 17.0.6 to Clang 18.1.5 through brew package manager. I had few test programmes that had the std::println
which worked fine with the Clang 17.0.6. Now with Clang 18.1.5 I get the below error message:
Undefined symbols for architecture arm64:
"std::__1::__is_posix_terminal(__sFILE*)", referenced from:
std::__1::__print::__is_terminal[abi:ne180100](__sFILE*) in main.cpp.o
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)`
I am not sure if the support of std::println
or the <print>
header library was removed from Clang 18.1.6? I have tried to search the release notes but did not find anything related to this topic. I am by the way specifying the C++ standard as 23 in my CMakeLists.txt
It was a linker issue to the proper libc++. I am not sure what happened with the brew update that it changed installation locations without having the symbolic links. I have reinstalled llvm via brew and got the below messages:
To use the bundled libc++ please add the following LDFLAGS:
LDFLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++"
llvm is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have llvm first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc
For compilers to find llvm you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
So, I have added the below line to my CMakeLists.txt, and everything then worked as it is supposed to with std::println
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With