Compile the. a library file used by iOS, and compile the ios. a library

Source: Internet
Author: User

Compile the. a library file used by iOS, and compile the ios. a library

First, the source file to be compiled into.

 

Hello. h:

#ifndef __INCLUDE_HELLO_H__#define __INCLUDE_HELLO_H__void hello(const char *name);#endif // end __INCLUDE_HELLO_H__


Hello. c

#include "stdio.h"void hello(const char *name){    printf("Hello world %s\n", name);}


1. Use xcode to create a library project



2. Configure

Delete the original. h and. m:



Add the above. c and. h to the project:



The minimum configuration item is iOS6.0.




3. Compile and obtain libhello..


Open the Directory and check that the. a library of the simulator and the. a library of the real machine have been generated at the same time.




4. The. a library generated for testing in the test project

Simulator:




Real machine (the library to be loaded must be different ):





5. Merge the real library and simulator library into one

Use lipo-create (three files to be merged together)-output (file name to be merged together)

First, copy the two files to the desktop, modify the corresponding name, one is libhelloi386.a and the other is libhello7.a, and then execute the following command on the terminal:





6. The entire test project (including the iOS test project and lib Library Project)

Http://download.csdn.net/detail/zengraoli/8115253 (csdn)


How can I decompress the IOS file? Static Library

Right-click to decompress the package.
 
When compiling the minix operating system, there is always a prompt that the file with the suffix a is not found. What is the file? How to generate?

The. a file is a set of. o files. You can use the ar-TV command to view the. o files contained in it.

Tips for ADS compilation options



Today, I received an input method file from star of Chinese and found that the generated library file is. a suffix, because it is used. the suffix in lib format is also worried that a problem may occur when the suffix name is directly modified. a. lib file.

In command line mode, enter the armar query parameters and find several required parameters:

-X Extract members in <file_list> placing in files of the same name.

-T Print table of contents of archive.

-Create Force creation of a new archive.

Then, enter armar-t csk2.a to view the list of component files of the library file, and then enter armar-x csk2.a to decompress all files. o file, and finally armar-create csk2.lib *. o. csk2.lib is successfully generated. Comparing csk2.a and csk2.lib, we found that there is a number that is different. It is estimated that the generation time is different. Now, you can simply change the suffix. Although it has taken a detour, many useful functions have been found through the query of compilation parameters. Here we will not list the parameters attached, so I will study them slowly.

-R Insert files in <file_list>, replace existing members of the same name.

-D Delete the members in <file_list>.

-X Extract members in <file_list> placing in files of the same name.

-M Move files in <file_list>.

-P Print files to stdout.

-A pos Insert/move files after file named <pos>.

-B pos Insert/move files before file named <pos>.

-U Update older files only, used with-r.

-N Do not add a symbol table to an object archive.

-S Force regeneration of archive symbol table.

-T Print table of contents of archive.

-Zs Show the symbol table.

-Zt Summarize the archive contents (sizes + entries ).

-C Suppress warning when a new archive is created.

-C Do not overwrite existing files when extracting.

-T Truncate file names to system maximum length.

-V Give verbose output.

-Create Force creation of a new archive.

-Via file Take additional arguments from via file.

-Sizes List th ...... remaining full text>

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.