Doubts about arm instruction set, static library operation, compiling error and so on

Source: Internet
Author: User

Reprinted from Http://www.jianshu.com/p/4a70aa03a4ea?utm_campaign=hugo&utm_medium=reader_share&utm_content=note &utm_source=qq

The question of the arm instruction set, the static library running problem, looked over a lot of information, organized as follows:

1:blog.csdn.net/lizhongfu2013/article/details/42387311

The following links are forwarded from the above link: iOS development ~ Making a static library that supports armv7,armv7s,arm64,i386,x86_64 at the same time. A, the article is very detailed, can have a clearer understanding.

I. Summary

In peacetime project development, may use the third party to provide the static library. A, if the. A provider technology is immature, problems can arise when using it, such as:

Compile error on the real machine: No architectures to compile for (Only_active_arch=yes, ACTIVE arch=x86_64, valid_archs=i386).

Compile error on Simulator: No architectures to compile for (Only_active_arch=yes, ACTIVE arch=armv7s, Valid_archs=armv7 armv6).

To solve these problems, you need to know some details about Apple's mobile device processor instruction set.

Ii. several important concepts

1, ARM

ARM processor, characterized by small size, low power consumption, low cost, high performance, so almost all mobile phone processors are based on arm, embedded systems in a wide range of applications.

2. ARM processor Instruction Set

Armv6|armv7|armv7s|arm64 are all ARM processor instruction sets, which are backwards compatible, such as ARMV7 instruction set compatibility ARMv6, only when using ARMV6 can not play its performance, can not use the new ARMV7 features, This can lead to less efficient program execution.

There are two more familiar instruction sets: I386|x86_64 is the instruction set for Mac processors, and i386 is for Intel's Universal microprocessor 32 architecture. The x86_64 is a 64-bit processor for the x86 architecture. So when using the iOS emulator you will encounter the I386|x86_64,ios emulator without an arm instruction set.

3, the current iOS mobile device instruction set

arm64:iphone5s| ipad air| ipad mini2 (ipad mini with Retina Display)

Armv7s:iphone5|iphone5c|ipad4 (IPad with Retina Display)

Armv7:iphone3gs|iphone4|iphone4s|ipad|ipad2|ipad3 (The New iPad) |ipad mini|ipod Touch 3g|ipod TOUCH4

ARMV6 devices: IPhone, IPhone2, IPHONE3G, first-generation, second-generation IPod Touch (usually no need to support)

4. The instruction set related options in Xcode (Build setting)

(1) Architectures

space-separated List of identifiers. Specifies the architectures (ABIs, processor models) to which the binary is targeted. When this builds setting specifies more than one architecture, the generated binary could contain object code for each of the Specified architectures.

Specifies which instruction set types the project is compiled to support, and the more supported instruction sets, the more the packets that contain multiple instruction set codes will be compiled, and the larger the binary package is, the larger the IPA package will be.

(2) Valid architectures

space-separated List of identifiers. Specifies the architectures for which the binary is built. During the build, this list was intersected with the value of archs build setting; The resulting list specifies the architectures the binary can run on. If The resulting architecture list is empty, the target generates no binary.

Limit the scope of the set of instructions that may be supported, that is, the type of binary package that Xcode compiles, and the package that compiles which instruction set is determined by the intersection of architectures and valid architectures (hence this cannot be empty), for example:

For example, the supported arm instruction set version of your valid architectures setting is: armv7/armv7s/arm64, the supported arm instruction set version of the corresponding architectures setting is: armv7s, Then Xcode will only generate a binary package of the armv7s instruction set.

Another example: Set the architectures support arm instruction set to: armv7,armv7s, the corresponding valid architectures the supported instruction set is set to: armv7s,arm64, then at this time, The set of instructions supported by the Xcode generation binary package is only armv7s

In Valid architectures settings in Xcode6.1.1, the default is standard architectures (armv7,arm64), and if you want to change it, make your own changes in other.

The reasons are explained as follows:

Using the standard architectures (including 64-bit) (armv7,arm64) parameter, the package contains 32-bit, 64-bit, two-part code, under IPHONE5S (IPhone5S CPU is 64-bit), Would prefer to run a 64-bit code package, the rest of the iphone (the remaining iphone is 32-bit, IPHONE5C is also 32-bit), can only run 32-bit packages, but contains two kinds of architecture of the code package, only run on the IOS6,IOS7 system.

That is to say, this packing method, to the handset almost no request, but to the system has the request, namely IOS6 above.

Instead of using the standard architectures (armv7,armv7s) parameter, there are only 32-bit codes in the package, and the IPHONE5S CPU is 64 bits, but it is compatible with 32-bit code, which can run 32-bit code. However, this can degrade the performance of iphone5s. The rest of the iphone has no problem with the 32-bit code pack, and the 32-bit code pack has almost no limitations on the system.

So the summary is as follows:

To play the IPhone5S 64-bit performance, the 64-bit package is included, then the system minimum requirement is IOS6. If you want to be compatible with IOS5 and lower systems, you can only hit 32-bit packages, the system can be universal, but will lose the performance of iphone5s.

(3) Build Active Architecture only

Specifies whether to compile only the set of instructions supported by the current connected device

When the value is set to Yes, this property is set to Yes to compile faster when debugging, it compiles only the current version of architecture, and when set to No, all versions are compiled. The compiled version is backwards compatible, and the instruction set match for the connected device is from high to low (Arm64 > Armv7s > ARMv7) in turn.  For example, if you set this value to Yes, the ARMV7 version is compiled with iphone4, Iphone5 can also run, but the ARMV6 device cannot run. Therefore, the general debug when you can choose to set the yes,release when you want to change to no, to adapt to different devices.

1)

Architectures:armv7, armv7s, arm64

Validarchitectures:armv6, armv7s, arm64

Generating the instruction set supported by the binary package: arm64

2)

Architectures:armv6, ARMv7, armv7s

Valid architectures:armv6, armv7s, arm64

Generating the instruction set supported by the binary package: armv7s

3)

Architectures:armv7, armv7s, arm64

Valid architectures:armv7,armv7s

This is an error because there is no arm64 allowed in the instruction set.

Note: If you have requirements for the size of the IPA installation package, you can reduce the number of instruction sets for the installation package, so that you can reduce the size of the package as much as possible. Of course, this will cause some of the equipment performance loss, of course, in general applications this is almost not felt, at least not to threaten the user's physical examination.

Third, the production of Static library. A is the instruction set selection

Now back to the point, how to make a "no problem". A static library, through the above information to understand, when we do the app, in order to pursue high efficiency, and reduce the size of the package, Build Active Architecture only set to Yes, Architectures by the Xcode default configuration, because arm64 is forward compatible. But make. A static library is different, because to ensure compatibility, including different iOS devices and emulator operation is not wrong, so combined with the current industry situation, to achieve maximum compatibility.

Validarchitectures set to: armv7|armv7s|arm64|i386|x86_64

Architectures settings are the same (or as you need them): armv7|arm64

Then select the iOS device and the emulator to compile, and finally find the relevant. A to carry out the package, using the Lipo-create real hangar. A's Path simulator library. A's path to the-output Composite Library name. A (for details, refer to http://blog.csdn.net/ lizhongfu2013/article/details/12648633)

In this way, a common static library is created. A

2. The static library does not support 64-bit, compile error and so on.

Make sure your the static library has which architectures.

lipo-info mystaticlibrary.a on terminal

Ios-xcode 6.1 Missing Required architecture x86_64 in File-stack Overflow

Doubts about arm instruction set, static library operation, compiling error and so on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.