Search code examples
iphoneiosios4zbar-sdk

How to build ZBar SDK with the project instead of using the static library?


I am building an iOS, code scanner project using ZBar SDK. I am trying to build my project directly from the source of ZBar, rather than including the libzbar.a static library.

I have downloaded the ZBar source which includes the XCode project to build libzbar.a. I tried copying all source files from the project but it didn't work. I keep on getting undefined symbol errors.

What source files should be included, considering that I need to support only iOS?

Should the folder structure be strictly followed to build the project?

Would there be any need of build settings if I direcly include the source files?

EDIT: I followed the same folder structure and build settings used in the XCode project of libzbar. I have managed to build the library but it's still failing while linking. I get the error: ld: duplicate symbol _OBJC_METACLASS for all the source files. I have double checked, there are no references to the original libzbar.a static library in the project or more than one occurrence of these source files. If I remove the references for them, the project builds fine, but then fails whenever any symbol from the library is referenced. I think I am still missing something!!


Solution

  • I have solved this problem finally. Here are the steps that I did:

    1) Copied the source files of the project to my project.

    2) Removed the dependency of libzbar.a from my project.

    3) Added the path to the folder containing the source and headers to the Header Search Paths build setting of the project.

    4)Added the following user defined build setting to the project:

    EXCLUDE_SOURCE_FILE_NAMES
    GCC_MODEL_TUNING
    PREBINDING and
    USE_HEADERMAP