0

We've implemented a static library and trying to use it on the project. The library is compiled/build well but as we try to run the project after importing .a & .h files respectively, we encountered with following error :

ld: warning: ignoring file Lib.a, file was built for archive which is not the architecture being linked (i386)

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_MFourInOneStaticLib", referenced from:
      objc-class-ref in MAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've already checked the architecture.More-over, we're using the simulator for the testing purpose.

Sirko
  • 72,589
  • 19
  • 149
  • 183
Mohit_Jaiswal
  • 840
  • 6
  • 10

1 Answers1

2

well looks the your lib doesnt contain the right architecture.

for ios you need armv7 and for the simulator you need i386

to test it

lipo -info %NAME%

often a lipo is only built for EITHER arm OR x86

built it for both archs and then combine the two files

lipo ./build/Release-iphoneos/%NAME% ./build/Release-iphonesimulator/%NAME% -output ./Dist/lib/%NAME% -create
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • Thanks for your early response. Actually, since we require ios3.0 as well as ios 4.0 compatibility, so we're using both the architecture armv6 and armv7.Also, we've added the i386 for testing purpose at simulator but still the error is same. Also, please elaborate me how to use 'lipo' tool as this is really a new concept for us. – Mohit_Jaiswal Nov 20 '12 at 11:08
  • it would be the same with armv6 :) lio -info %NAME% = prints architectures inside lib, libo F1 F2 -output F3 -create combines F1 and F2 ... basically just appending them to each other and saves it as F3 – Daij-Djan Nov 20 '12 at 11:18
  • At terminal what should we use instead of %NAME%, as per our understanding the syntax which is provided by you will be execute over the terminal ? – Mohit_Jaiswal Nov 20 '12 at 11:28
  • %NAME% == your static library. actually ./build/Release-iphoneos/%NAME% == the full path to your file – Daij-Djan Nov 20 '12 at 11:52
  • Djan, really appreciate your assistance but just after spending my long time on this problem, I just found an option to work-around of this problem. What we did, at the static library project, for the base-sdk option instead of "iphoneos", we'll use "iphonesimulator" and rest is fine. As, when we again think for testing at the real device, then we again change it to "iphoneos". – Mohit_Jaiswal Nov 20 '12 at 12:08
  • But, will definitely try to make use of lipo, as I think it'll be a great if I can use it. – Mohit_Jaiswal Nov 20 '12 at 12:10
  • :( anyways glad you figured it out. lipo is a bonus :D – Daij-Djan Nov 20 '12 at 14:11