Why can't I get rid of libstdc++? - ios

Since upgrading to xcode 10 beta 6 I'm getting the error
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I know that libstdc++ has been removed from the iOS simulator but the project and all the targets have C++ Standard Library set to libc++, not libstdc++.
The project has nothing set in Other Linker Flags. The summary of the Other Links Flags for the target includes -stdlib=libstdc++
but when I double-click on it to edit it, it isn't in the list.
What is it that's sneaking libstdc++ in? Any help would be greatly appreciated!

It turned out the problem was that one of my dependencies was using libstdc++, so Cocoapods was adding the -stdlib=libstdc++ to the linker flags for the project.
The solution was to update the dependency to a newer version that had been built against libc++.
If anyone else has trouble identifying which dependency is using libstdc++ then I recommend removing $(inherited) from your target's linker flags. That will cause the linker to report missing symbols from the place that's using it, giving away which library has the problem.

Related

Error building xcode project when i add a library with extension .a

I have an Xcode project and I need to add a static library with extension .a who sent me for integrated a functionality. I added the library in Build Phases - Link Binary With Libraries, but when I compile my project with this library I added, I does not compile and shows this error:
could not parse object file /routelibrary/libraryname.a(IosHttp.o): 'Unknown attribute kind (45)Unknown attribute kind (45)Unknown attribute kind (45)', using libLTO version 'Apple LLVM 7.0.0 (clang-700.0.72)' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any idea on how can I solve it?
One possible reason is missing Other Linker Flags in your target build settings.
First check if you need to set any Other Linker Flags in documentation of your static library, and if yes, what that flag is.
For example so many libraries needs -ObjC as Other Linker Flags.
To find Other Linker Flags, do following.
Select Build Targets in your Xcode project.
select Build Settings.
In Search Box type Other Linker Flags
check and set your flags here.

Xcode 7 simulator error "duplicate symbols for architecture x86_64"

My development environment with Xcode 7.2.1, CocoaPods 1.0.0 and GoogleMaps 1.13.2
I can build code successful to generate a XXX.ipa file and install in my iPhone 6 Plus to work correctly.
But when I run Xcode simulator by item "iPhone 6" or "iPhone 6 Plus" always get the information as below
"xxxx duplicate symbols for architecture x86_64" "linker command
failed with exit code 1 (use -v to see invocation)"
I use the following solutions still can't fix it
Build Options -> Enable Bitcode -> set "No"
Remove -ObjC from Other Linker Flags
project Targer -> Build phases -> compile sources, ckeck no duplicate files
Make sure I haven't #imported a .m file
I am wondering if there are any other method to solve this, help would be appreciated thanks.
This error generally occurs when you have linked any library or file twice.
In the error desciption, the name of the duplicated file will be listed, you can search and and make sure you don't have duplicates.
If you find duplicates, remove reference to one of them to play safe
I have faced similar kind of issue.
In my application I have run my code and created ipa before two day. And today when I am trying to run same code without any changes I am getting:
ld: 102 duplicate symbols for architecture x86_64 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
The solution for this duplication Linker error can be solved by Remove all of your classes from compile sources, then click the + button and search for the term '.m'. Highlight every class, then click add. Build and run again.
This problem can also be occurred in case you import ".m" file instead of ".h" by mistake. I know it may be seemed as a stupid advise but this is what I had done in my case.
I resolved this issue by removing the -all_load flag in the Build Settings-> Other Linker flags.

Linking Errors while integrating SKMaps.Framework

Getting these error while trying to integrate SKMaps framework
Undefined symbols for architecture x86_64:
"CRouteTestManager::calculateRoute(NGRouteInput const&, std::__1::shared_ptr<CRoute>&)", referenced from:
PoiTrackerTest::createRoute() in SKMaps(PoiTrackerTest.o)
"_gpTestRoutesManager", referenced from:
PoiTrackerTest::createRoute() in SKMaps(PoiTrackerTest.o)
createNavigationObject(int) in SKMaps(NavigationTest.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please help me resolve this error.
Environment :
Xcode 6.3.1, Mac OSX 10.10.3
Deployment Target iOS7.0
Supports Swift.
i was following this guide : http://developer.skobbler.com/getting-started/ios
and also added CoreMotion.framework as there were also linking errors related to that framework.
Cause of Linker Error
This appears to be the result of the linker flag -all_load, which may have been added to your project through a CocoaPod. In the rare case that you have a static library with nothing but categories defined then you need this flag. Otherwise, it can be safely removed from your build. See discussion here:
What does the -all_load linker flag do?
From a link in the comments section on that discussion you can see that this bug that previously required -all_load has been fixed since XCode 4.
Objective-C categories in static library
Probable Explanation
This framework has a bunch of tests defined inside, but their dependencies are not included in the framework. When the linker is forced to resolve and link all dependencies, it errors out because it cannot find them. Basically, the library should be cleaned up so that it doesn't contain these unnecessary symbols. The work around is to remove -all_load for the time being.
Faced with the same problem. Deleting -all_load flag did not help, so I continued to research and found a solution:
Despite the fact that Skobbler declares the need for linking the libc++ library, in reality you need to link libstdc++.6 library. Note that linking libstdc++ will not help.
P.S. Xcode 6.4, iOS SDK 8.4

Cannot Archive when a library is included in my own iOS custom framework

I created my own iOS framework by following this tutorial, https://code.google.com/p/ios-static-framework/, which uses a static library template and aggregate target with a custom run script to create a framework.
At first it works fine. After including another library in the framework project creates the error when archive or build for device. I think the problem is with some wrong settings for that library. But I just don't know what to try. I have tried setting some sensible Other Linker Flags from https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ld.1.html , but no luck. Can anyone help please ;(
What steps will reproduce the problem?
Follow the tutorial, but change the Aggregate script architecture from armv6 armv7 to armv7 armv7s. Here is the part of the aggregate target script I changed. Everything else is the same.
if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
then
SF_OTHER_PLATFORM=iphonesimulator
SF_ARCHS=i386
else
SF_OTHER_PLATFORM=iphoneos
SF_ARCHS="armv7 armv7s"
fi
Add an external library to the project, here I use libBlocksKit.a.
Build the framework, success.
In another child project. Include my built framework.
Add -ObjC in the app Target > Build Settings > Other Linker Flags
Archive and get error. Building for device (iPhone5) gives error too. But building for simulator seems to work.
What is the error?
This error, basically "ld: warning: directory not found for option ... ld: lto: could not merge in ... symbol multiply defined!".
ld: warning: directory not found for option '-L/Users/hlung/Dropbox/- Notes/stackoverflow/RealFrameworkApp/RealFrameworkApp/External/BlocksKit'
ld: lto: could not merge in /Users/hlung/Library/Developer/Xcode/DerivedData/RealFrameworkTest-evagqzwzyyolhjenkkjbvzibxppf/Build/Products/Debug-iphonesimulator/RealFrameworkTest.framework/RealFrameworkTest(NSObject+BlockObservation.o) because 'Linking globals named 'OBJC_CLASS_$_BKObserver': symbol multiply defined!', using libLTO version 'LLVM version 3.2svn, from Apple Clang 4.2 (build 425.0.28)' for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I archive my child project with only one architecture (like armv7), it works. It shows this error with armv7 armv7s architectures ( $(ARCHS_STANDARD_32_BIT) ).
What version of the product are you using? On what operating system?
OS X 10.8.5, XCode 4.6.3
== Update 1 ==
Posted an issue at the tutorial's code.google.com page Update: 2 weeks no answer.
I found a set of useful suggestions from this answer. Update: Doesn't work
I have created a project so you can run and see for yourself here
Linking against a static library from within a framework can create some interesting challenges... It sounds like you may be linking to BlocksKit from both your framework and your application projects.
You should link in only one of those places. Try removing libBlocksKit.a from the Link Libraries build phase of your framework, but leave it in the other project.
You can do like this:
Click on your project (targets)
Click on Build Settings
Under Library Search Paths, delete the paths
I hope it can help you.

clang: error: linker command failed with exit code 1 (use -v to see invocation) when setting up cocoapods environment

I am setting the cocoapods dependency management tool for iOS project, when building my project i got this error:
ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am using Xcode 4.5 and Mac OS X Lion 10.7.4. Thanx in advance.
Can't comment yet, so posting as an answer.
It would help to have a bit more information on what you did to setup cocoapods, library settings in XCode and whether this is your first time using cocoapods or if the issue suddenly started. Try to give us a good idea of the details of your current situation.
For the time being, a little googling popped up this URL: https://github.com/CocoaPods/CocoaPods/issues/155
You might find it helpful, specifically the post near the bottom:
In my environment the issue was that the Pods project did not have a
target called ADHOC (as per the main project). I duplicated the Pods
release target, called it ADHOC, changed the OS Deployment Target to
my requirement (5.0) and then everything worked.

Resources