Recently, I upgraded to Xcode 15, and with that the update of the xcodebuild tools. However, suddenly, my standalone C++ applications are not able to use the g++-13 compiler for some reason? Anyone knows what might work, I don't want to downgrade to Xcode 14.
From Apple's internal employees, this is the fault of Homebrew, you can either wait for Homebrew to fix it or try other ways to install GNU tools.
Update 2023-11-05: Some users reported problems after ignoring this warning, see the answer by danny below.
The Homebrew team responded to the GitHub issue ld: warning: ignoring duplicate libraries: '-lemutls_w', '-lgcc' #4794 on Sep 19, 2023, with:
"Yes, this is an incompatibility of current gcc with the Xcode 15 and/or CLT 15. The warning is not a problem, and we will ship a fixed version in the future."
A commenter asked here on SO:
Is it safe to ignore the warnings? (from a commenter)
Yes. To get rid of the warnings, what worked for me was the suggestion to add the following linker flags for gcc:
-Wl,-ld_classic
ld_classic
is the old Mach object file link editor.
The ld_classic command combines several Mach-O (Mach object) files into one by combining like sections in like segments from all the object files, resolving external references, and searching libraries. In the simplest case several object files are given, and ld_classic combines them, producing an object file which can either be executed or become the input for a further ld_classic run. (In the latter case, the -r option must be given to preserve the relocation information.) Unless an output file is specified, ld_classic produces a file named a.out. This file is made executable only if no errors occurred during the link editing and there are no undefined symbols.
(excerpt from man page)
A Workaround
If you'd like to silence the warning in the meantime, add this line exactly as-is to the other linker flags
in your project's build settings within Xcode:
"-Wl,-no_warn_duplicate_libraries"
I am not sure that Xcode and gcc are the only thing causing this . I have the same issue with ld: warning: ignoring duplicate libraries: '-lgcc'
I have it running on one system building with no issues and get the above error on another. I am using gcc-13 on both systems and they have the same version of Xcode. Now the working system has the whole xcode but the new system does not. The main difference of these systems is the working one is intel and the other is the mac default chip. However, I do not see how the would effect it.
I tried ld-classic info above but it still fails. It causes my built to fail. I did have -wall set but I removed that and it still dies.
For Go programmers seeing this warning when running go test or other go CLI commands, I was able to silence this warning by adding this env:
export CGO_LDFLAGS="-Wl,-no_warn_duplicate_libraries"
© 2022 - 2025 — McMap. All rights reserved.
Ignoring duplicate libraries: '-lc++', '-lsqlite3', '-lz'
– Gander