Duplicate symbol error in Xcode

22,675

Solution 1

Those symbols are in crt.o, the startup code of standard C library. Normally it should be the entry point of executable file to initialize global variables and objects. It will also call your main function.

But for a framework, you should not include it in your binary because framework should not have main. I believe you have "Link with Standard Library" option as "YES" in your framework's target build setting. This will link crt.o into your framework. And when you link the framework into a project, there will be duplicated symbols.

Please set the option "Link with Standard Library" to NO in your build setting.

Solution 2

I had the same issue with using two third party framework. I resolved that by removing "all_load" from "Other Linker Flags" in build settings.

Solution 3

Your application has provided an implementation in which there are 8 duplication symbols.

There are a number of ways you might have done this:

You have two modules declaring the same class. Perhaps one is no longer needed?

You are importing any header file in both the files .m and .h :-( Remove from one place.)

You are importing any .m file somewhere. :- (Import .h file instead of .m file)

You have defined and declared any const variable in outside(above) the @interface{} in any of .h file, it might being duplicated. :- (Do it in the .m file.)

Solution 4

Also check, if global variables like constants are defined correctly in .h file in application.

The correct way of defining global variable is to use extern variable in .h file.

Note :This is not an issue with the previous Xcode version. I faced the problem with Xcode 6.3 and it was solved.

Share:
22,675
user591410
Author by

user591410

Updated on May 01, 2020

Comments

  • user591410
    user591410 almost 4 years

    I am encountering 'duplicate symbol' errors in Xcode 4.5.1 when I try to build a project after adding my own framework. I verified the framework files for duplicates and there are none. But when I add the framework to a project, it complains with these error. Please suggest..

    duplicate symbol _NXArgc in:
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
    /Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
    
    duplicate symbol _NXArgv in:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
    /Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
    
    duplicate symbol ___progname in:
      /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
    /Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
    
    duplicate symbol _environ in:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
    /Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
    
    duplicate symbol start in:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
    /Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
    ld: 8 duplicate symbols for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    Thanks in advance..

  • Tam Borine
    Tam Borine over 7 years
    When I set Link with Standard Library to no in build settings, I got 177 compiler errors instead of 1