about other link flag

Source: Internet
Author: User

The targets option has the other linker flags set to fill in Xcode's linker parameters, such as:-O bjc-all_load-force_load.

Remember when we were learning the C program, the steps from C code to the executable file were:

Source code > Preprocessor > Compiler > Assembler > Machine code > Linker > executable file

In the final step, you need to link the. o file with the C language runtime, which requires the use of the LD command. After a series of processing of the source files, a corresponding. obj file is generated, and then a project will inevitably have many. obj files, and there will be a variety of connections between these files, such as function calls. The thing that the linker does is to link these target files with some of the libraries used to form a complete executable file.

If you want to examine in detail what the linker has done, see: http://www.dutor.net/index.php/2012/02/what-linkers-do/

Then, the value set by other linker flags is actually the parameter that is added later when the LD command executes.

The following 3 common parameters are described individually:

-OBJC: When this parameter is added, the linker will load all the Objective-c classes and categories in the static library into the final executable file

-all_load: will let the linker load all the found target files into the executable file, but do not use this parameter arbitrarily! If you use more than one static library file, and then use this parameter, then you are likely to encounter ld:duplicate symbol error, because different library files may have the same target file, so it is recommended to use when encountering-OBJC failure-force_ The load parameter.

-force_load: What you do is exactly the same as-all_load, but-force_load needs to specify the path to the library file to be loaded completely, so you simply load a library file without affecting the rest of the library file's on-demand loading

Solution: Modify link parameters (other Linker Flag)

1. Remove the-objc-all_load parameter (this parameter will force all static link libraries to load the category);

2. Instead of loading each static library of XXXX, modify the link parameter (other Linker Flag) to the following form:

-force_load $ (built_products_dir)/xxxxx.a

about other link flag

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.