herzbube / littlego

Little Go. An iOS application that lets you play the game of Go on the iPhone or iPad.
https://littlego.herzbube.ch/
Apache License 2.0
138 stars 54 forks source link

Building with Xcode 15 emits warning: Ignoring duplicate libraries: '-lc++' #410

Open herzbube opened 7 months ago

herzbube commented 7 months ago

A standard build of this project with Xcode 15 generates the following warning:

ld: warning: ignoring duplicate libraries: '-lc++'

What does the warning mean?

Xcode 15 introduced a new linker (see the Xcode 15 release notes). Apparently with this linker it is no longer necessary to explicitly link the C++ standard library runtime. If you do add the -lc++ linker flag, though, then the linker emits the warning above.

Apparently somewhere, somehow, the project seems to pick up the -lc++ flag.

Analysis

The project itself no longer sets the -lc++ linker flag, but it inherits this flag from the generated CocoaPods project. It is currently not clear why CocoaPods sets the -lc++ flag, but in any case the flag can be found in the various generated .xcconfig files. Search for the flag like this:

$ grep -ri -- c++ Pods | grep -- -l | cut -d":" -f1 | sort | uniq
Pods/Target Support Files/Pods-All Targets-Little Go/Pods-All Targets-Little Go.debug.xcconfig
Pods/Target Support Files/Pods-All Targets-Little Go/Pods-All Targets-Little Go.distribute_adhoc.xcconfig
Pods/Target Support Files/Pods-All Targets-Little Go/Pods-All Targets-Little Go.distribute_appstore.xcconfig
Pods/Target Support Files/Pods-All Targets-Little Go/Pods-All Targets-Little Go.release.xcconfig
Pods/Target Support Files/Pods-All Targets-Unit tests/Pods-All Targets-Unit tests.debug.xcconfig
Pods/Target Support Files/Pods-All Targets-Unit tests/Pods-All Targets-Unit tests.distribute_adhoc.xcconfig
Pods/Target Support Files/Pods-All Targets-Unit tests/Pods-All Targets-Unit tests.distribute_appstore.xcconfig
Pods/Target Support Files/Pods-All Targets-Unit tests/Pods-All Targets-Unit tests.release.xcconfig

Example line from one of the files:

OTHER_LDFLAGS = $(inherited) [...] -l"c++" [...]

Status / Workaround

The linker warning is nothing serious and can effectively be ignored.

To get rid of the warning temporarily you can manually edit the .xcconfig files and remove the -l"c++".