Linker command failed with exit code 1

Source: Internet
Author: User

This problem usually occurs when you add a third-party library file or when you develop multiple people.

This problem is usually a link error that is caused by a file not being found. We can proceed from the following aspects of the investigation.

1. Take the following error as an example, if you are a multi-person developer, you will find the following error when you complete the synchronization.

[HTML]View Plaincopy
    1. Undefined Symbols for Architecture armv7:
    2. "_objc_class_$_mypagelogviewcontroller", referenced from:
    3. Objc-class-ref in BAIDUMOBSTATAPPDELEGATE.O
    4. Ld:symbol (s) not found for architecture armv7
    5. Clang:error:linker command failed with exit code 1 (use-v to see invocation)

The "Mypagelogviewcontroller" class appears in the error, and you can find the. m file for this class and see his target membeship, as

If it is not checked, click on the check box. And then compile the view.

2. If it is a newly added third-party library and is not a static library

Repeat the first step and then find the Build settings->linking->other Linker Flags

Modify this property to-all_load or-OBJC, depending on the situation. In short, you can try more than a few times.

3. If you are adding a third-party static library (. a file)

[HTML]View Plaincopy
    1. Undefined Symbols for Architecture armv7:
    2. "_objc_class_$_baidumobstat", referenced from:
    3. Objc-class-ref in BAIDUMOBSTATAPPDELEGATE.O
    4. Objc-class-ref in MYPAGELOGVIEWCONTROLLER.O
    5. (Maybe you meant: _objc_class_$_baidumobstatappdelegate)
    6. Ld:symbol (s) not found for architecture armv7
    7. Clang:error:linker command failed with exit code 1 (use-v to see invocation)

Errors have occurred in all files used in this library, such as the Baidumobstatappdelegate class and the Mypagelogviewcontroller class

This could be a link error caused by this static library path confusion.

Workaround: Build settings->search path->library Search Paths Add the appropriate path to the static library. Such as

If none of the above methods works. You can try a few more ways:

1 to see if there is a newly added file with the same name as the previous file

2, the error message appears in the name of a class, go to the original file to see what the third-party library, the library #import, find out the wrong library, and then follow the official steps to re-add again.

Statement two:

Linker command failed with exit code 1 (use-v to see invocation) error debugging
Situation 1,


Linker command failed with exit code 1 (use-v to see invocation) This error seems to have met and more than once, when I want to use a third-party class library (such as Sbjson), I directly copy the library file into the project directory Face, and then a compilation of such errors (not necessarily will make such an error), began to think that the library itself is the download of the problem, so re-find the class library or other ways to add it, as long as the line is not wrong, and has not been in-depth understanding of the fundamental problem, today in the project to add a Fmdb ( SQLite third-party library) file compile time again this error occurred, initially thought engineering problems, but after the new project still appeared this problem, after online search, got the solution;

[CPP]View Plaincopy
    1. Undefined Symbols for Architecture i386:
    2. "_objc_class_$_fmdatabase", referenced from:
    3. Objc-class-ref in VIEWCONTROLLER.O
    4. Ld:symbol (s) not found for architecture i386
    5. Clang:error:linker command failed with exit code 1 (use-v to see invocation)


The solutions available online are:

In the left navigation bar of the work target-->build phases-->compile sources, all the. m files of the third library are added to the inside, and then compiled through;

Add. m file

Depending on the comparison, you can see that the in Fmdbtest,fmdbtest target adds some. m files

For the above error, according to the Netizen answer my understanding is

When we use these third-party library files, we drag them directly into the project, and when we compile it, Xcode does not automatically refer to it, so this error can be caused by adding it manually. If we create a new file in the project, there will be no such problem;

Reference http://blog.hsin.tw/2012/ios-dev-undefined-symbols-for-architecture-i386/

Situation 2,

Linker command failed with exit code 1 (use-v to see invocation)

It is likely that many of the same files were introduced in the project. Delete one on ok!
Situation 3,

A compile error for Xcoder:

Linker command failed with exit code 1 (use-v to see invocation)

Indicates that there is a function that cannot be found accurately, and the function has a repeating phenomenon.

The reason for this error is that I implemented several functions directly in the. h header file, and then the header file was referenced by another. c file and implemented.

So the solution is to put the implementation of a few functions out of a. c file. This will be OK.

Situation 4,

Change the value of Valid architectures to ARMV7

Process:

PROJECT--Build Settings--and architectures--Valid architectures his value was ARMv7 armv7s (ios6.0) Remove armv7s Can

The same operation

TARGETS---Build Settings---architectures and Valid architectures make the same changes

Situation 5, very wonderful situation ah, refers to the third party's static library. A there was a problem. The static libraries introduced in the simulator and the real machine are separate!!! Of course, if your static library is made unified, there will be no scenario 5.

Linker command failed with exit code 1

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.