Resolved Link error: missing required architecture i386 in file

Discussion in 'iOS Programming' started by potash, Jun 16, 2011.

  1. potash, Jun 16, 2011
    Last edited: Jun 16, 2011

    potash macrumors newbie

    Joined:
    Jun 16, 2011
    #1
    Hi, I'm a newbie to iOS programming. Using xcode 4.0.2. I created an iPhone static library project and built a test library libTest.a. Then in a separate iPhone application project, I tried to link with the static library and got the error:

    Code:
    Ld /Users/eccl224/Library/Developer/Xcode/DerivedData/Test_Hello-avzmwtnikzskcgdayrbfnffnhsxu/Build/Products/Debug-iphonesimulator/Test_Hello.app/Test_Hello normal i386
        cd /Users/eccl224/Applications/Test_Hello
        setenv MACOSX_DEPLOYMENT_TARGET 10.6
        setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/eccl224/Library/Developer/Xcode/DerivedData/Test_Hello-avzmwtnikzskcgdayrbfnffnhsxu/Build/Products/Debug-iphonesimulator -L../Test -L/Users/eccl224/Applications/Test_Hello/../Test -F/Users/eccl224/Library/Developer/Xcode/DerivedData/Test_Hello-avzmwtnikzskcgdayrbfnffnhsxu/Build/Products/Debug-iphonesimulator -filelist /Users/eccl224/Library/Developer/Xcode/DerivedData/Test_Hello-avzmwtnikzskcgdayrbfnffnhsxu/Build/Intermediates/Test_Hello.build/Debug-iphonesimulator/Test_Hello.build/Objects-normal/i386/Test_Hello.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -lTest -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/eccl224/Library/Developer/Xcode/DerivedData/Test_Hello-avzmwtnikzskcgdayrbfnffnhsxu/Build/Products/Debug-iphonesimulator/Test_Hello.app/Test_Hello
    
    ld: warning: ignoring file ../Test/libTest.a, missing required architecture i386 in file
    Undefined symbols for architecture i386:
      "_new_MyTest", referenced from:
          _myTest in Test_HelloAppDelegate.o
    ld: symbol(s) not found for architecture i386
    collect2: ld returned 1 exit status
    In the build settings, both library and application projects are targeting iphonesimulator, iphoneos in the supported platforms, and the Standard (armv6 armv7) architecture. Why does the xcode tried to link with i386 flag? Can somebody please let me know how this can be resolved?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    It seems the library is built for phone deployment (ARM) but you are trying to link it to a simulator executable (x86). This won't work. Rebuild the library for the simulator.
     
  3. potash thread starter macrumors newbie

    Joined:
    Jun 16, 2011
    #3
    I changed the Base SDK to iphonesimulator and it works now, thanks!
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Remember that you'll need to change it back to compile for the actual device. I imagine it'll be easy to forget. I've never used static libraries in my iOS apps but it would seem that there should be a way to have both simulator and device builds of the library available and have XCode automatically use the correct one. Perhaps someone who has more knowledge in this area will pop in with a solution...
     

Share This Page