Hello,
I have lost a couple of days to figure this out so maybe this will help someone and save them some time.
My scenario was like this: I have a game written in Cocos2dX for iPhone and Android and one of the features needed was to scan a qr code, so I have chosen zbar for both implementations.
On iPhone was pretty straight forward, as it is very easy to mix c++ with obj c and so adding a new view controller for zbar view did the trick.
For Android the principle is almost the same, but the project kept crashing until I have done this steps:
- download this zbar library project I have found on zbar forum: https://github.com/DushyanthMaguluru/ZBarScanner
- add the project as library to your project
- move libgame.so from your project to ZBarScanner project
- Change first part of Android.mk to look like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := iconv
LOCAL_MODULE_FILENAME := libiconv
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
………………………………………………………………
That’s it. I don’t know if this is the best way to do it but now the project is working just fine.
To call zbar screens from cocos2dx you should use JNI as described here: [[http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_use_jni]]
Thank you for this great cocos2d port!