Reputation: 299
After updating Xcode Version to 10.0 beta start getting "ld: library not found for -lstdc++.6" error. same code working fine in Xcode 9.2
Also updated macOS to 10.13.5
Upvotes: 29
Views: 28044
Reputation: 1867
I was trying to compile C program and got ld: library not found for -lc++
Because of deprecation as mentioned and the work around that to tell C++ to read from old mac sdk /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
# adjust your llvm and CLT include paths to match your setup
export CPLUS_INCLUDE_PATH=/usr/local/opt/llvm/include/c++/v1:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
# then set correct var for compiler lib
export LIBRARY_PATH=$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib
nice walkthrough at fixing-cpp-compilation-bugs-for-the-mac-os-catalina-upgrade
Upvotes: 0
Reputation: 2957
This was failing for me when trying to do a make install
. Instead, I ran make install -stdlib=libc++
, which did the trick.
Upvotes: 1
Reputation: 297
The quick solution is to copy all libstdc++.* file from old Xcode(9.4) to new Xcode(10.x)
For device :
cp /Applications/Xcode9.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libstdc++.* /Applications/Xcode10.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/
For Simulator :
cp /Applications/Xcode9.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libstdc++.* /Applications/Xcode10.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
Upvotes: 13
Reputation: 1354
Simply go to build settings, Link binary with libraries and there remove this.It resolved my issue.
Upvotes: -2
Reputation: 6126
CXXFLAGS += -stdlib=libc++
your external library Makefile and removed instances of -stdlib=stdlibc++
Upvotes: 5
Reputation: 452
As said above lstdc++ is removed from Xcode 10. To fix this,
Go to Target -> BuildPhases -> Link Binary With Libraries
Search for lstdc++ and remove it.
Now you might get error in some framework which uses the above said "lstdc++" library. Now either you have to update those framework or remove it so that Xcode can build it successfully.
Upvotes: 7
Reputation: 26026
You'll have this issue when targeting iOS App. It's stated in the Release note:
Deprecation Notices:
Building with libstdc++ was deprecated with Xcode 8 and is not supported in Xcode 10 when targeting iOS. C++ projects must now migrate to libc++ and are recommended to set a deployment target of iOS 7 or later. Besides changing the C++ Standard Library build setting, developers should audit hard-coded linker flags and target dependencies to remove references to libstdc++ (including -lstdc++, -lstdc++.6.0.9, libstdc++.6.0.9.tbd, and libstdc++.6.0.9.dylib). Project dependencies such as static archives that were built against libstdc++ will also need to be rebuilt against libc++. (40885260)
Source: Release Notes of XCode Beta 2
Side Note:
You need to be logged to access the page.
Link might break in next beta release (URLs change), but it's in the part Developers/Download
XCode 10 being officially released with its release note, it's still as such:
Building with libstdc++ was deprecated with Xcode 8 and is not supported in Xcode 10 when targeting iOS. C++ projects must now migrate to libc++ and are recommended to set a deployment target of macOS 10.9 or later, or iOS 7 or later. Besides changing the C++ Standard Library build setting, developers should audit hard-coded linker flags and target dependencies to remove references to libstdc++ (including -lstdc++, -lstdc++.6.0.9, libstdc++.6.0.9.tbd, and libstdc++.6.0.9.dylib). Project dependencies such as static archives that were built against libstdc++ will also need to be rebuilt against libc++. (40885260)
Upvotes: 14