xcode 4.5 - symbols not found for architecture i386 (zbar)

woopsicle picture woopsicle · Sep 23, 2012 · Viewed 10.8k times · Source

I have a project which uses the zbar-sdk (a barcode scanning library).

After updating my machine to xcode 4.5 and ios6sdk I am having some troubles.

I was able to build to the simulator without touching anything about my project. This is using the latest zbar 1.2 library.

I then wanted to build to my ios6 device for testing, and thats when I got an error.

After some googling on the zbar developer forum, I seen that I needed to get the zbar source and build the libzbar.a for armv7 and armv7s as this has not yet been done by the zbar developer.

See - http://sourceforge.net/projects/zbar/forums/forum/1072195/topic/5728912

So I did this, re-imported the updated libzbar.a into my project. I then built for my device, and it worked! I was able to get my app onto my testing device and the zbar barcode library worked fine.

I thought that was the end of it, but unfortunately not.

I then tried to build to the simulator (ios6) again, and thats when it fails.

No matter what I cannot get this project to build for both the device and simualtor at the same time and with the same settings :(

My libzbar.a project settings when building my own libzbar.a file:

Architecture: Standard (armv7, armv7s) $(ARCHS_STANDARD_32_BIT)

Build Active Architecture Only: No

Valid Architectures: armv7 armv7s

And my project settings (for myapp) as:

Architecture: Standard (armv7, armv7s) $(ARCHS_STANDARD_32_BIT)

Build Active Architecture Only: No

Valid Architectures: armv7 armv7s

Base SDK: iOS6

iOS Deployment Target: iOS 5.0

And the error when trying to build to the simulator:

ld: warning: ignoring file /Users/blah/iOS App/myapp/ZBarSDK/libzbar.a, missing required architecture i386 in file /Users/blah/iOS App/myapp/ZBarSDK/libzbar.a (2 slices)
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_ZBarReaderViewController", referenced from:
      objc-class-ref in mycontroller.o
  "_ZBarReaderControllerResults", referenced from:
      -[mycontroller imagePickerController:didFinishPickingMediaWithInfo:] in mycontroller.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have tried tweaking the libzbar.a project settings (e.g. build active architecture set to "YES") but this just results in neither the simulator or device working.

The fact that it works on the device but not the simulator makes me thing there is some weird architecture/project setting causing this.

Any help much appreciated!

Answer

Holyprin picture Holyprin · Sep 25, 2012

I doubt this is the right answer but it worked for me, I compiled the new libzber.a using architectures: i386 armv6 armv7 armv7s in that order you also need to specify valid architectures as the same values. Again this is what worked for me with a recent release I needed to get out A.S.A.P. Both are found in Target -> Build Settings -> Architecures.

Also note: $(ARCHS_STANDARD_32_BIT) needed to be removed from the settings.