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

3

9

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!!

Mellifluous answered 25/3, 2012 at 13:27 Comment(2)
ZBar is an open source project, distributed as a static library only to make it easier to integrate, not because developers don't want people to see the source code. In fact if you go through the project site, the link to download the source is just below the link to download the static library.Mellifluous
@rakeshNS all the errors are either missing header files or undefined symbols.Mellifluous
M
3

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

Mellifluous answered 30/3, 2012 at 10:20 Comment(3)
Where did you download the source code? which classes do I need to include?Frisky
@Odelya the source code is available at sourceforge.net/projects/zbar .I included all the classes from the source code.Mellifluous
@Mellifluous Can you provide some more details on 3) & 4) step or screen shot or something that can help me to understand as I am new to iOSDunno
S
0

You should create the static library your self from the source code then add the output static library to your project, or link the projects together and force a build of the static library before your project is build.

After downloading the zip file from the default Mercurial repository and opening the file in xCode, click on the "EmbedReader" part of the target selection drop down box and switch to "zBarSDK"

Once you switch to the zBarSDK, just build from the product menu and you should have your static library file....

Serilda answered 25/3, 2012 at 14:51 Comment(1)
Thanks for your answer Lefteris but that part is quite apparent. I plan to do some major changes in the code and want the code to be easily maintainable by other developers in the future. Changing the code directly in the project, if need arises, seems to be a better option to me than opening a separate project, making the changes, compiling a library and then including in the main project again.Mellifluous
A
-1

I used ZXing lib before and it integrated well. It was included as a project and main project has target dependency to build it before main project. I edited it's sources for my needs and have no problems working with it.

I used this tutorial. It can be helpful for your needs too.

Aloud answered 29/3, 2012 at 11:5 Comment(1)
Thanks for your answer Alivig but somehow zxing doesn't suit my requirements. I have to use zbar only.Mellifluous

© 2022 - 2024 — McMap. All rights reserved.