Skip to content

Compiling zbar for leanXcam

Beat Küng edited this page Jul 16, 2012 · 3 revisions

Table of Contents

Introduction

zbar is an open-source bar code reader implementation supporting a wide range of bar code types. It exists as a library, which can be linked to your application.

Used versions
Compilation steps

1) Build libiconv. Zbar uses libiconv for Qr code decoding. If you don't use QR, you might want to skip this step.

CROSS_COMPILE=bfin-uclinux-
CC=bfin-uclinux-gcc
export CROSS_COMPILE CC
  • create build-leanxcam dir in your new libiconv dir
  • build for blackfin target using:
./configure --prefix=/home/oscar/libiconv-1.14/build-leanxcam --target bfin-uclinux --host bfin-uclinux
make
make install
  • now your leanxcam-ready libiconv resides in build-leanxcam
2) Build zbar with minimal config, no jpeg, no video, no x, nothing except decoders.
  • download zbar source from http://zbar.sourceforge.net/ and decompress in oscar home
  • if you use a different terminal as for libiconv, set cross-compile vars
CROSS_COMPILE=bfin-uclinux-
CC=bfin-uclinux-gcc
export CROSS_COMPILE CC
  • create build-leanxcam dir in your new zbar dir
  • configure for blackfin target with all options disabled (you can disable even more if you do not use all decoders):
./configure --prefix=/home/oscar/zbar-0.10/build-leanxcam --without-imagemagick --without-qt --without-gtk --without-python --enable-video=no --without-x --without-jpeg --enable-pthread=no --enable-shared=no --target bfin-pc-uclinux --host bfin-pc-uclinux
  • hack Makefile to add libiconv to the linker library options. Here's how I did it:
    • look for var LTLIBICONV and set to:
      LTLIBICONV = -L/home/oscar/libiconv-1.14/build-leanxcam/lib -liconv
    • add libiconv include path to existing DEFAULT_INCLUDES var
DEFAULT_INCLUDES = -I. -I$(top_builddir)/include -I/home/oscar/libiconv-1.14/build-leanxcam/include
  • build:
make
make install
  • now your leanxcam-ready libzbar resides in build-leanxcam
3) Build your app with zbar and iconv libs. I used web-view-cpp with a customized image_processing.cpp. The steps required for your application may differ. The important parts are to include the zbar.h file and linking to iconv and zbar libraries.
  • in your web-view-cpp dir, create links to the build directories in zbar and iconv
ln -s /home/oscar/libiconv-1.14/build-leanxcam/lib iconv
ln -s /home/oscar/zbar-0.10/build-leanxcam zbar
  • include <zbar.h></zbar.h> (or zbar/include/zbar.h) in image_processing.cpp. Don't forget do add
 using namespace zbar;
./configure
  • hack Makefile to add libzbar and libiconv:
    • add zbar include path ( i used CFLAGS var): CFLAGS := -c -Wall -Ioscar/include -Izbar/include
    • add zbar and iconv libs anywhere you can ( i used LINK target ): $(LD_target) -o $$@ $$^ $(OSC_CC_LIBS_INC) -lm -lbfdsp $(OSC_CC_LIBS_target) $(OPENCV_LIBS_target) -Lzbar/lib -lzbar -Liconv/lib -liconv
  • make target. As we only modified the target build, you will have errors by just typing "make". If you want also zbar support for the host build, do the same Makefile adjustments for the host target, but linking with the i386 versions of the iconv and zbar libs (not described here)
make target
  • here's finally your zbar enabled leanxcam app: app_target. Deploy it and test! You might need to clean up /mnt/app on the cam if your executable is big. Mine is 3.5 Mb and just fits on flash.
Credits

These instructions have been contributed by Axel von Arnim. Thanks a lot!

Clone this wiki locally