Compiling zbar for leanXcam
Beat Küng edited this page Jul 16, 2012
·
3 revisions
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.
- leanxcam BusyBox 1.13.4
- oscar scs-oscar-212a7a1
- osc-cc scs-osc-cc-56b3154
- libiconv 1.14
- libzbar 0.10
- web-view-cpp example code https://github.com/scs/web-view-cpp
1) Build libiconv. Zbar uses libiconv for Qr code decoding. If you don't use QR, you might want to skip this step.
- download libiconv source from http://www.gnu.org/s/libiconv/ and decompress in oscar home
- set cross-compile vars (as explained in http://docs.blackfin.uclinux.org/doku.php?id=cross_compiling):
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
- 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
- look for var LTLIBICONV and set to:
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
- 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 with your preferred options (see https://github.com/scs/web-view-cpp)
./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.
These instructions have been contributed by Axel von Arnim. Thanks a lot!