linker error while linking to arm64 library on Xcode - ios

I'm trying to build my project for arm64. This project requires an arm64 libcrypto.a. I'd like to know if I'm missing any settings. Thanks in advance...
The error I see is:
ld: warning: ignoring file /Users/Amy/Desktop/swift_proj/swift_proj/include/libcrypto.a, file was built for archive which is not the architecture being linked (x86_64): /Users/Amy/Desktop/swift_proj/swift_proj/include/libcrypto.a
My project settings are shown below:
Architectures: arm64
Base SDK: Latest iOS(iOS 11.4)
Build Active Architecture Only: No
Supported Platforms: iOS
Valid Architectures: arm64
I've updated "RequiredDeviceCapabilities" in info.plist to arm64.
I've checked the type of library I'm trying to link with:
[Amys-MacBook-Air:include$ lipo -info libcrypto.a
input file libcrypto.a is not a fat file
Non-fat file: libcrypto.a is architecture: arm64
I fail to understand why the error says the project is being built for x86_64.

Looks like OpenSSL has some issues with multi-arch builds that you need to address for it to work, the answer here Build Multiarch OpenSSL on OS X should help.
Essentially, you'll have to replace a couple of the OpenSSL header files that include the architecture-specific header using #ifdef to check the system architecture at compile time. Do this after building OpenSSL from source for each target that you want. Then you'll be able to use the lipo tools to combine each target's static library build for OpenSSL into one static library, then use that.

Related

How to remove unwanted architecture x86_64 from Xcode build?

I am trying to recompile someone else's code. The code includes a reference to a third party library myLib.a, which has two slices:
Architectures in the fat file: myLib.a are: armv7 arm64
I get this warning, following by a bunch of link errors:
ld: warning: ignoring file myLib.a, missing required architecture x86_64 in file myLib.a (2 slices)
Now, I know this library is not intended to work in a simulator. So I want to throw the simulator away from build. I don't really understand build targets, so I did this:
Still, same error. What am I doing wrong?
Xcode 7.3
I answered this question here: https://stackoverflow.com/a/65307436/5303139
Same anwser
For an iOS project, you have the following architectures: arm64 armv7 armv7s i386 x86_64
x86_64, i386 are used for the simulator.
What could be your problem is the framework you are using was build for iOS and not a simulator.
To fix this issue you can bypass the build framework and use lipo command lines.
First: lipo -info [The library.framework location]
Example Usage : lipo -info /Users/.../library.framework/LibrarySDK
Example output :
Architectures in the fat file: /Users/.../library.framework/LibrarySDK are: i386 x86_64 armv7 arm64
You will get the list of architecture used for that framework.
Second: we need to strip the framework from the simulator architecture and make 2 versions of that framework (1 is used for iOS Device and 1 for the simulator)
using: lipo -remove [architecture] [location] -o [output_location]
Example: lipo -remove i386 /Users/.../SDK -o /Users/.../SDK_Output_Directory
Go to your chosen output directory to get the new generated SDK without the removed architecture to verify you can use the lipo -info command same as above
You can use the same lipo remove command on the newly created SDK but with another architecture
lipo -remove x86_64 ... and you will get an SDK only for iOS devices
Third: Take that final SDK and rename it "SDK_Name_IOS" and use it.
Happy coding!!
You did set architect to armv7, arm64 so just change Build Active Architecture Only to YES in debug mode:
debug mode: YES
release mode: NO (default value)
So when debug you will build only for current device

missing required architecture x86_64

I have an old project, that I recompiled for an uodate, and it is now showing this error message:
…. missing required architecture x86_64 in file myLibrary.a ….
I have tried various tricks that I could find on the net after searching on missing required architecture x86_64 in file, but with no success. Anyone knows how to properly handle the issue?
I am using Xcode Version 7.0.1.
Running:
lipo -info myLibrary.a
shows:
Architectures in the fat file: myLibrary.a are: armv7 arm64
I have been able to add armv7s but not x86_64.
You are trying to build a universal library and it does not have all the architectures in it armv7 armv7s i386 x86_64 arm64. Compiler is complaining when you build with 64 bit architecture.
To fix this - Add the following to your architecture settings of static library project:
This needs manual addition of architectures something like this:
Build the library with these architecture both on device & simulator, create fat library using lipo -create -output "myLibrary.a" ./Simulator/myLibrary.a ./Device/myLibrary.a and use it.

missing required architecture x86_64 in ...libMumbleKit.a (3 slices)

I am trying to include MumbleKit as a library instead of having to compile it each time by following the suggestion of a member of this forum. Yet when I try to compile on the simulator I get:
missing required architecture x86_64 in …libMumbleKit.a (3 slices)
I think I added all the necessary versions to MumbleKit before generating the library:
arm64 armv7 armv7s armv7k arm7s x86_64 i386
notwithstanding, when I execute:
lipo -info libMumbleKit.a
I get:
Architectures in the fat file: libMumbleKit.a are: armv7 armv7s arm64
as well as configuring Build Active Architecture to NO.
I generated the library for MumbleKit both using the Generic iOS device and a iOS 9 physical device.
When I try to archive using the Generic iOS Device option after having extracted the Mumble library in the same way, I instead get error:
ld: bitcode bundle could not be generated because
'/Users/fbartolom/Documents/cocoa
applications/inArrivoHD/MumbleKit/libMumbleKit.a(CryptState.o)' was
built without full bitcode. All object files and libraries for bitcode
must be generated from Xcode Archive or Install build for architecture
armv7
Same when using my physical device after also generating the library in the correspondent way:
ld: bitcode bundle could not be generated because
'/Users/fbartolom/Documents/cocoa
applications/inArrivoHD/MumbleKit/libMumbleKit.a(CryptState.o)' was
built without full bitcode. All object files and libraries for bitcode
must be generated from Xcode Archive or Install build for architecture
arm64
And finally the installation on my iOS 9 iPhone 6S went fine with just the same contents in the warning:
ld: bitcode bundle could not be generated because
'/Users/fbartolom/Documents/cocoa
applications/inArrivoHD/MumbleKit/libMumbleKit.a(CryptState.o)' was
built without full bitcode. All object files and libraries for bitcode
must be generated from Xcode Archive or Install build for architecture
arm64
CryptState.cpp if a c++ file in the library.
Check architectures it has with lipo tool. Open terminal, navigate to folder where your library is and do:
lipo -info yourlib.a
If you don't have x86_64, than you should find/compile lib that will have it.
x86_64 is an architecture for Simulator, not for generic iOS device.
I applied the suggestion at:
Xcode 7 'CrashReporter does not contain bitcode' linker error
by adding option -fembed-bitcode to the other linker flags field. And now the problem has moved to a c file: band.c, notwithstanding of course I have added this option for the c and c++ files.
ld: bitcode bundle could not be generated because
'/Users/fbartolom/Documents/cocoa
applications/inArrivoHD/MumbleKit/libMumbleKit.a(bands.o)' was built
without full bitcode. All object files and libraries for bitcode must
be generated from Xcode Archive or Install build for architecture
arm64
What might be still missing?
I aborted the attempt. There must be something faulty in the original mumble kit project not allowing to import its library into another project, or I do not know how to do it anyway.

Library not found for -lpj-arm-apple-darwin9 [duplicate]

This question already has answers here:
How can I "add existing frameworks" in Xcode 4?
(10 answers)
Closed 8 years ago.
I downloaded pjsip source code from online.It is running without any error.But, I integrated openssl lib and include file into that pjsip > ipjsua xcode project.After compiled xcode project, am getting library not found error and warning like below,
ld: warning: directory not found for option '-L"/Users/aahlaad/Desktop/swyxpjsip/iospj2/pjproject-2.2.1/pjsip-apps/src/pjsua/ios/../../../../pjlib/lib"'
ld: warning: directory not found for option '-L"/Users/aahlaad/Desktop/swyxpjsip/iospj2/pjproject-2.2.1/pjsip-apps/src/pjsua/ios/../../../../pjlib-util/lib"'
ld: warning: directory not found for option '-L"/Users/aahlaad/Desktop/swyxpjsip/iospj2/pjproject-2.2.1/pjsip-apps/src/pjsua/ios/../../../../pjmedia/lib"'
ld: warning: directory not found for option '-L"/Users/aahlaad/Desktop/swyxpjsip/iospj2/pjproject-2.2.1/pjsip-apps/src/pjsua/ios/../../../../pjnath/lib"'
ld: warning: directory not found for option '-L"/Users/aahlaad/Desktop/swyxpjsip/iospj2/pjproject-2.2.1/pjsip-apps/src/pjsua/ios/../../../../pjsip/lib"'
ld: warning: directory not found for option '-L"/Users/aahlaad/Desktop/swyxpjsip/iospj2/pjproject-2.2.1/pjsip-apps/src/pjsua/ios/../../../../third_party/lib"'
ld: library not found for -lpj-arm-apple-darwin9
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Delete your derived Data and
Go to Project->Build Settings->Search Paths
and remove everything from Framework/Header/Library Search Path respectively and add your frameworks again in Project -> General ->Linked Frameworks and Libraries
ld: library not found for -lpj-arm-apple-darwin9
Here's how to add headers and libraries under Xcode. Its shows how to add OpenSSL, but in your case, do the same for PJSIP.
Headers:
Libraries:
If your PJSIP library has both static archives and shared objects, then delete the shared objects. Even though iOS only allows static linking, Xcode will still link against a shared object if available. Apparently, the Xcode developers did not get the memo.
If you need help adding the PJSIP library to Xcode so it shows up under Frameworks and Libraries, then see How to “add existing frameworks” in Xcode 4?.
If you get the PJSIP library added but are missing architectures, you can use the following to see what's in the fat library:
$ xcrun -sdk iphoneos lipo -info /usr/local/ssl/ios/lib/libcrypto.a
Architectures in the fat file: libcrypto.a are: armv7 armv7s arm64 i386
Ideally, you will have the four architectures: ARMv7, ARMv7s, ARM64 and i386. i386 is for debug builds under the simulator.
If you are missing an architecture, then you should re-build the library with the missing architecture, and then use lipo to combine the different architectures into a single fat library.

file was built for archive which is not the architecture being linked (armv7s)

I'm using the new OData4ObjC framework for IOS 6, but when I try to run it keeps telling me this error.
I have followed the instructions found here https://github.com/ElizabethDuncan/OData4ObjC.
I also changed the framework to an older one to see if that is the problem. I don't know if I'm missing something.
In the future, to check what architectures a library/executable is compiled for you should use the lipo -info command. Like so:
mitchellge$ lipo -info /Users/mitchellge/Downloads/libMSODataLib.a
--> Architectures in the fat file:
/Users/mitchellge/Downloads/libMSODataLib.a are: armv6 armv7
As you can see, the library (libMSODataLib.a) that is bundled with OData4ObjC is compiled for the armv6 and armv7 architectures and not the armv7s. One fix is to go into your project's build settings and change Valid Architectures from armv7 armv7s to just armv7

Resources