Sunday, July 26, 2015

cocos2dx + opencv static linking

I spent much time to get it work.

There is a Japanese blog showing how to setup cocos2dx with opencv, but there is one missing part.
http://blog.szmake.net/archives/845

It works for OPENCV_LIB_TYPE:=SHARED. It is also the default option of opencv for android. But it fails on OPENCV_LIB_TYPE:=STATIC and there will be linking errors.

The reason is that cocos2dx uses static linking by default and overrides opencv's libs. So you need to update LOCAL_STATIC_LIBRARIES := cocos2dx_static to LOCAL_STATIC_LIBRARIES += cocos2dx_static. Now the project compiles.

Again, you need 

OpenCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=off
OPENCV_LIB_TYPE:=STATIC

include /path/to/OpenCV.mk

LOCAL_C_INCLUDES+= /path/to/OpenCV/include

LOCAL_STATIC_LIBRARIES += cocos2dx_static

No comments:

Post a Comment