FedericoCappelli.net Me, my software and a little bit of my life

5Oct/1250

Zbar library for iphone 5 (armv7s)

(updated 02/10/2013)

Updated procedure for XCode 5: http://stackoverflow.com/questions/18740304/linker-error-in-xcode-5/18937831#18937831

(updated 08/10/2012)

In this moment the great qr/bar code reader library ZBar (SourceForge link) don't work on iPhone 5 simply because no one has re-compiled the library for armv7, and if you try to use this lib in you armv7s ready ios project you obtain:

ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/rainbird/Desktop/myapp/iFileManager/iFileManager/ZBarSDK/libzbar.a for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

here two solutions:
The easy and ready to cook solution: Download and include my re-compiled library (support armv6-7-7s and i386) from HERE (note: no warranty, no support, nothing, if don't work delete it ;) )

The advanced solution: re-compile yourself the libzbar.a following this steps:

1 - Download the source code (you must have Mercurial for mac):

hg clone http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbar
cd zbar 
hg checkout iPhoneSDK-1.2.2 (20/03/2013 new version available? hg checkout iPhoneSDK-1.3.1)
open iphone/zbar.xcodeproj

2 - In the xcode project edit the "libzbar" scheme and select Release in Build configuration

libzbar_scheme

 

3 - Compile libzbar for device AND for simulator, here the configuration:

4 - Find the compiled libzbar.a and go in the folder using Teminal.app, my folder:

/Users/kappe/Library/Developer/Xcode/DerivedData/zbar-gyozyrpbqzvslmfoadhqkwskcesd/Build/Products

In this folder you you should have two sub folder Release-iphoneos and Release-iphonesimulator

5 - using xcode command line tools build you universal lib:

lipo -create Release-iphoneos/libzbar.a Release-iphonesimulator/libzbar.a -o libzbar.a

the end ;) now you can use the libzbar.a created, both in device and simulator.

Update:

When you make "Product -> Archive" to avoid the error:

'Cordova/CDVViewController.h' file not found

add this fields:

"$(BUILT_PRODUCTS_DIR)"
"$(OBJROOT)/UninstalledProducts/include"
"$(TARGET_BUILD_DIR)/usr/local/lib/include"

to Your taget - > Building settings -> Header search paths

facebook comments:

Comments (50) Trackbacks (0)
  1. Will you be recompiling this for Xcode 5.1?

  2. Me too facing the same problem. I have the libzbar.a in the elease-iphoneos/folder

  3. Worked for me too. Great. Thanks.

  4. With thanks! Excellent stuff!

  5. Worked for me. Thank you.

  6. Thank you for these instructions. I saw someone on StackOverflow who had a problem with the ZBar library and pointed them to your tutorial. I also updated it for Xcode 5 and gave you full credit (since I couldn’t have written up my own tutorial without yours as a guide).

    http://stackoverflow.com/a/18937831/155167

  7. Works for me. Thanks!

  8. Cheers, a life-saver :-) I was a bit stumped when I hit this problem but your solution worked perfectly!

  9. Thx you saved my life ;)

  10. Thankyou … you just saved my life!!!! :)

  11. Hi,
    i ‘ve compiled the library and imported into my project , but now i’ve this error :

    Undefined symbols for architecture armv7:
    “_CMSampleBufferGetImageBuffer”, referenced from:
    -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o)
    “_CMSampleBufferIsValid”, referenced from:
    -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o)
    “_CMSampleBufferDataIsReady”, referenced from:
    -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o)
    “_CMSampleBufferGetNumSamples”, referenced from:
    -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o)
    ld: symbol(s) not found for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation).

    with the simulator is all ok but with my iphone 5
    i get the errors..Can you please help or send me a library that work with iphone 5 and Xcode 4.6.1
    Thanks

  12. Well done, worked perfectly!

  13. note that the current version is 1.3.1,
    so you’ll have to use
    hg checkout iPhoneSDK-1.2.2
    to get the current version

  14. Thank you very much.

  15. Thanks, your recompiled Lib helped me…

  16. Having been merely looking at helpful blog articles with regard to the project research when My partner and i happened to stumble on yours. Thanks for this practical info!

  17. Thanks for the detailed step-by-step post! Saved a lot of time.

  18. Thanks Federico, for the instructions and also for providing a ready-to-go package – very much appreciated.

  19. Thank you very much!

  20. Thanks much. Your download worked with no problems.

    You saved me the step of having to build for myself.

  21. Hi! Do you use Twitter? I’d like to follow you if that would be okay. I’m definitely enjoying your blog and look forward to new updates.

  22. XCode says build succeeded and the libzbar.a exists in both folders. The one for the simulator works, the other for the device does not, neither does the result if i combine them with the command line tools.
    Seems pretty odd to me…

  23. Yes, i have a libzbar.a in both folders and xcode also says that the build succeeded for both the simulator and the device. I can also combine them with the command line tools…
    Seems pretty odd to me…

  24. Thank you very much for this, it was of great help.

    *buys you a virtual pint*

    Cheers :)

  25. Thanks so much! Great workaround

  26. Hi Federico:
    Thanks a lot for your detailed instructions to recompile the Zbar library, none of the other solutions I found worked for me. Now my project’s back on track.

    Best regards!
    Raul

  27. Thanks so much for this step by step guide. Worked perfect for me the first try!!

  28. Hm… i tried your workaround, but still i got the same error as before.
    Are there any special Build Settings i have to make?


Leave a comment

No trackbacks yet.