Linker error in iOS build when including static library - ios

I am working on importing a static library on our company's project. While I see so many questions on this topic, I tried all of them and none solved my problem.
Here is what I tried.
1) I have added the libraries in Build settings -> Link Binary with libraries. The static libraries are there.
2) I added the path of the static libraries ( They are fat static libraries for armv7, armv7s & arm64 ) in Search paths.
3) I tried turning on/off Build Active Architecture only.Valiant.
I am very new to iOS development and would be grateful with some help. Right now, I am just trying to import the library and build it. I have attached screenshots of my settings.

It looks like that library is calling c++ functions (std::new, std::string, etc.) You need to link to the C++ standard library. You can do this by by going into your project's build settings and look for "C++ Standard Library" and set it to libc++

Related

Symbols not found for architecture when building Cocoa Framework used in Static Library subproject

I built a pretty simple Cocoa Framework in Xcode for use on an iOS device (not simulator). I dropped this framework into another project that builds a static library. When I build this static library it succeeds without error. No problems yet.
NOW:
I have an actual iOS app project that includes the static library project as a subproject.
When I try building this app I get 'no symbols found for architecture' errors regarding the two classes I am trying to use that are defined in my cocoa framework:
I'm not only building the framework for the active architecture:
I've verified that it is indeed built for both armv7 and arm64 in Terminal:
Kevins-MBP-2:ASI.framework kevin$ lipo -info ASI
Architectures in the fat file: ASI are: armv7 arm64
The only way to get this building successfully is if I also drop my cocoa framework into the iOS app project, in addition to it already existing in my static library project. I feel like I shouldn't have to have the framework in both projects. Only the static library actually uses the framework. The iOS app project does not need to know about the framework.
Static libraries don't contain dependent libraries, so whenever you link against a static library you need to supply the dependent libraries they use to the linker.
Basically you do need to also link the executable against this Cocoa Framework as you have stated in the last sentence of your question.

Error compiling Redis library into iOS Project ("_OBJC_CLASS_$_ObjCHiredis", referenced from:)

I am trying to integrate the simulator static library of Redis into my iOS project and have done the following things.
drag and drop the static library into my project folder
Add header search path in the build settings
Check whether the static library is added into the build phases in settings.
Set the header search path
Set the other linker flags setting to "-all_load"
I am not sure where i have gone wrong but am geting the following error while compiling it.
Any help in this regard is greatly appreciated.
I was also getting such errors and figured out that adding .m files in "Build Phase" -> "Compile Sources" for the target fixed my problem.
Actually this happens if we miss to tick the Target Name in "Add to targets" name while adding any new library to it. (For your case, after drag and drop you might have seen a dialog box with options to copy items if needed, Add to target etc.)
Finally build and run. Hope this solves your problem!
The static library which you are dragging is not build for i386 architecture(simulator), try running your app on device, or build for device. Basically your app with the corresponding library will work on all such architectures for which it is built(armv7, armv64).
If you want to use the library and build your app on the simulator you need the static library which is also built for i386. And this could be provided by the developer of the static library.
Basically a fat(static library) file is created using static libraries for i386 and armv7(any required architectures) and shipped with the SDK of the static library which works on simulator as well as device.
The fat file is created by executing a lipo command on individual architecture static libraries.

How to integrate MuPDF in iOS project

How can I integrate the mupdf library into an existing iOS project? I can run the provided source on my device and simulator, but I can't seem to manage to add it to my project correctly. I tried linking and importing the compiled static libraries but it only works in the simulator, even if I use lipo to build a fat library with all the architectures (armv7 armv7s arm64 i386). In this case the error is
file was built for archive which is not the architecture being linked (armv7s)
Ideally i would like to have it added as a submodule for ease of upgrading, I tried that too, but i can't get xcode to recognize where the built libraries are.
I was able to generate and integrate the MuPDF library for all architectures.
I wrote a small step-by-step tutorial on this post.
I hope it will help you !
Cheers
The easiest way is probably to use the MuPDF CocoaPod. There is an example application based on that pod.

zxing in xcode 4.5 and ios 6

As many of you noticed; zxing does not work in latest xcode (4.5/ios 6)
Here is use case:
checkout latest version from trunk (as some fixes were already added)
create single view application in xcode 4.5 with ios 6.0
use README to add dependencies, paths etc (just follow step by step)
add zxingcontroller call to class (renamed to mm)
Compilation fails both for simulator and device
It shows 31 error like this one:
Undefined symbols for architecture i386:
"std::string::c_str() const", referenced from
all 31 errors are similar, difference is in symbols name
May be somebody knows how to solve it with this use case?
p.s. if you have app from previous Xcode, it works. Problem is only if you create new app in Xcode 4.5
The issue you have encountered seems to be C++ standard library related.
Actually, whenever you see linker failures in relationship with standard library objects (e.g. std::string), you should check the project settings on all linked libraries and the app-project itself. They usually need to match!
The original ScanTest (which builds ZXingWidget as a subproject) uses the following settings and those need to match your App build-settings if you use the library as is.
For making sure, I created a brand-new project using Xcode 4.5. That project uses ZXingWidget as a prebuilt library but not as a subproject - I dont like subprojects for stuff that is not my own - though this specialty wont influence the results.
The important setting is C++ Standard Library - make sure that is set towards Compiler Default
Little clarification
Actually, you do not need to use C++ Standard Library, you may as well use LLVM C++ standard library with C++11 support. But you will have to use that exact same library in all projects, sub-projects and libraries that link with your project. So if you insist on using the more recent version of that library (C++11 support), then you will have to build the ZXing library with those settings as well.
Last but not least, make sure your Architectures and Valid Architecture settings are matching over all projects and sub projects (fixing the common armv7s linker issue).
First, make sure your Architectures setting is set towards armv7 armv7s within all projects. Then also edit the project settings of all projects towards Valid Architecture armv7s armv7.
You might also want to switch the "Other Warning Flag" -Werror off. Seems to be necessary in Xcode versions > 4.5 (LLVM compiler > 4.1).
It works for me, have you enabled -lstdc++ in your list of Other Linker Flags in the Build Settings tab of the project target? It sounds like it is not recognizing the c++ symbols needed for zXing to build. If this is the case, the above advice should help.

Static lib linking error: Symbols not found for architecture

I need to link FFMPEG's libraries (libavformat, libavcodec, etc) to my project.
I have downloaded as an example iFrameExtractor project, and have successfully build it.
xcode-proj opens fine and the sample app works fine, so I just took libs from this project to my one.
But xcode fails to build it, saying me
Undefined symbols for architecture armv7:
"av_register_all()", referenced from:
I checked target settings, and I cannot see any difference between my project's settings and iFrameExtractor.
I just moved all ffmpeg folder to my project's folder.
Notes:
1) nm commands tells me that this symbol is inside the library.
2) library is fat-file, including i386, armv6, armv7 architectures.
Please, help me, what am I doing wrong?
I just went through this yesterday :-)
In xcode, you need to add the .a file to the list of linked libraries in the project. The easiest way to do that is by dragging the .a directly onto the project entry in the navigation area on the left:
Alternatively, you can select them from the dialogs in the summary area of the project editor:
Just make sure you select the actual .a files, not the whole folder. Then, simply import their headers (as you are likely already doing...), and you should be good to go :-)

Resources