Irrlicht openCV ndk, libpng, libjpeg multiple definition

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Irrlicht openCV ndk, libpng, libjpeg multiple definition

Post by kornwaretm »

i just starting android development. i try to make android app using irrlicht and opencv. i got a lot of multiple definition of 'jpeg_....' and 'png....' , both lib has libpng and libjpg. i can't think of a solution, should i merge the sources? what should i do to solve this?

here is my Android.mk file

Code: Select all

 # general
LOCAL_PATH := $(call my-dir)/..
IRRLICHT_PATH := D:\android_native\irrlicht_ogl_es
OPENCV_PATH := C:\OpenCV-android-sdk\sdk\native
TARGET_PROJECT_PATH := D:\android_native\openCVTest
 
# irrlicht
include $(CLEAR_VARS)
LOCAL_MODULE := Irrlicht
LOCAL_SRC_FILES := $(IRRLICHT_PATH)\source\Irrlicht\Android\obj\local\$(TARGET_ARCH_ABI)\libIrrlicht.a
include $(PREBUILT_STATIC_LIBRARY)
$(info +----------------------------------------------------------------------)
$(info |Irrlicht 3D)
$(info |include path : $(IRRLICHT_PATH))
$(info +----------------------------------------------------------------------)
$(info )
 
# open cv
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=on
OPENCV_LIB_TYPE:=STATIC
include $(OPENCV_PATH)\jni\OpenCV.mk
$(info +----------------------------------------------------------------------)
$(info |Open CV)
$(info |include path : )
$(info | $(OPENCV_LOCAL_C_INCLUDES))
$(info |Flag compiler : )
$(info | $(OPENCV_LOCAL_CFLAGS))
$(info |Components : )
$(info | $(OPENCV_MODULES))
$(info |3rd party Components : )
$(info | $(OPENCV_3RDPARTY_COMPONENTS))
$(info +----------------------------------------------------------------------)
$(info )
 
# main
include $(CLEAR_VARS)
LOCAL_MODULE := openCVTest
LOCAL_CFLAGS := -pipe -fno-exceptions -fno-rtti -fstrict-aliasing
 
    # debug mode or use speed optimization
    ifndef NDEBUG
    LOCAL_CFLAGS += -g -D_DEBUG
    else
    LOCAL_CFLAGS += -fexpensive-optimizations -O3
    endif
 
 
    #special flag for x86
    ifeq ($(TARGET_ARCH_ABI),x86)
    LOCAL_CFLAGS += -fno-stack-protector
    endif
    
LOCAL_C_INCLUDES := $(IRRLICHT_PATH)\include 
LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES)
 
LOCAL_SRC_FILES := main.cpp android_tools.cpp
 
#irrlicht and user flags
LOCAL_LDLIBS := -lEGL -llog -lGLESv1_CM -lGLESv2 -lz -landroid
# addition from opencv
LOCAL_LDLIBS += $(foreach lib,$(OPENCV_EXTRA_COMPONENTS), -l$(lib))
 
#opencv
LOCAL_WHOLE_STATIC_LIBRARIES := $(OPENCV_3RDPARTY_COMPONENTS) $(OPENCV_MODULES)
#irrlicht and project static libs
LOCAL_WHOLE_STATIC_LIBRARIES += Irrlicht android_native_app_glue
 
 
#summary
$(info +----------------------------------------------------------------------)
$(info +----------------SUMMARY------SUMMARY--------SUMMARY-------------------)
$(info +----------------------------------------------------------------------)
$(info |TARGET_ARCH_ABI : $(TARGET_ARCH_ABI))
$(info |LOCAL_MODULE : $(LOCAL_MODULE))
$(info |LOCAL_CFLAGS : $(LOCAL_CFLAGS))
$(info |LOCAL_C_INCLUDES : $(LOCAL_C_INCLUDES))
$(info |LOCAL_SRC_FILES : $(LOCAL_SRC_FILES))
$(info |LOCAL_LDLIBS : $(LOCAL_LDLIBS))
$(info |LOCAL_WHOLE_STATIC_LIBRARIES : $(LOCAL_WHOLE_STATIC_LIBRARIES))
$(info +----------------------------------------------------------------------)
$(info )
$(info )
 
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android\native_app_glue)
 
# copy Irrlicht data to assets
$(shell mkdir $(TARGET_PROJECT_PATH)\assets)
$(shell mkdir $(TARGET_PROJECT_PATH)\assets\media)
$(shell mkdir $(TARGET_PROJECT_PATH)\assets\media\Shaders)
$(shell mkdir $(TARGET_PROJECT_PATH)\src)
 
#copy all irrlicht shaders
IGNORE := $(shell copy /y $(IRRLICHT_PATH)\media\Shaders\ $(TARGET_PROJECT_PATH)\assets\media\Shaders)
some command prompt output

Code: Select all

D:\android_native\openCVTest>ndk-build
+----------------------------------------------------------------------
|Irrlicht 3D
|include path : D:\android_native\irrlicht_ogl_es
+----------------------------------------------------------------------
 
+----------------------------------------------------------------------
|Open CV
|include path :
| "C:/OpenCV-android-sdk/sdk/native/jni/include/opencv" "C:/OpenCV-android-sdk/sdk/native/jni/include"
|Flag compiler :
| -fPIC -DANDROID -fsigned-char
|Components :
| shape stitching objdetect superres videostab calib3d features2d highgui videoio imgcodecs video photo ml imgproc flann core
|3rd party Components :
| libjpeg libwebp libpng libtiff libjasper IlmImf tbb
+----------------------------------------------------------------------
 
+----------------------------------------------------------------------
+----------------SUMMARY------SUMMARY--------SUMMARY-------------------
+----------------------------------------------------------------------
|TARGET_ARCH_ABI : armeabi
|LOCAL_MODULE : openCVTest
|LOCAL_CFLAGS : -pipe -fno-exceptions -fno-rtti -fstrict-aliasing -g -D_DEBUG
|LOCAL_C_INCLUDES : D:\android_native\irrlicht_ogl_es\include  "C:/OpenCV-android-sdk/sdk/native/jni/include/opencv" "C:/OpenCV-android-sdk/sdk/native/jni/include"
|LOCAL_SRC_FILES : main.cpp android_tools.cpp
|LOCAL_LDLIBS : -lEGL -llog -lGLESv1_CM -lGLESv2 -lz -landroid  -lz  -ldl  -lm  -llog
|LOCAL_WHOLE_STATIC_LIBRARIES : libjpeg libwebp libpng libtiff libjasper IlmImf tbb shape stitching objdetect superres videostab calib3d features2d highgui videoio imgcodecs video photo ml imgproc flann core Irrlicht android_native_app_glue
+----------------------------------------------------------------------
 
 
A subdirectory or file D:\android_native\openCVTest\assets already exists.
A subdirectory or file D:\android_native\openCVTest\assets\media already exists.
A subdirectory or file D:\android_native\openCVTest\assets\media\Shaders already exists.
A subdirectory or file D:\android_native\openCVTest\src already exists.
[armeabi] Gdbserver      : [arm-linux-androideabi-4.9] libs/armeabi/gdbserver
[armeabi] Gdbsetup       : libs/armeabi/gdb.setup
[armeabi] Compile++ thumb: openCVTest <= main.cpp
[armeabi] Compile++ thumb: openCVTest <= android_tools.cpp
[armeabi] SharedLibrary  : libopenCVTest.so
 error: D:\android_native\irrlicht_ogl_es\source\Irrlicht\Android\obj\local\armeabi\libIrrlicht.a(jaricom.o): multiple definition of 'jpeg_aritab'
 C:/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi/liblibjpeg.a(jaricom.c.o): previous definition here
 error: D:\android_native\irrlicht_ogl_es\source\Irrlicht\Android\obj\local\armeabi\libIrrlicht.a(jcapimin.o): multiple definition of 'jpeg_CreateCompress'
 C:/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi/liblibjpeg.a(jcapimin.c.o): previous definition here
 error: D:\android_native\irrlicht_ogl_es\source\Irrlicht\Android\obj\local\armeabi\libIrrlicht.a(jcapimin.o): multiple definition of 'jpeg_destroy_compress'
 C:/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi/liblibjpeg.a(jcapimin.c.o): previous definition here
 error: D:\android_native\irrlicht_ogl_es\source\Irrlicht\Android\obj\local\armeabi\libIrrlicht.a(jcapimin.o): multiple definition of 'jpeg_abort_compress'
 C:/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi/liblibjpeg.a(jcapimin.c.o): previous definition here
 error: D:\android_native\irrlicht_ogl_es\source\Irrlicht\Android\obj\local\armeabi\libIrrlicht.a(jcapimin.o): multiple definition of 'jpeg_suppress_tables'
.............
thanks in advance
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht openCV ndk, libpng, libjpeg multiple definition

Post by CuteAlien »

You can modify IrrCompileConfig.h
There are defines like _IRR_USE_NON_SYSTEM_LIB_PNG_ and _IRR_USE_NON_SYSTEM_JPEG_LIB_ which are enabled by default. Disable those. Or if you don't want to modify the header you can pass it as compile-time options (in Irrlicht and your project) with -DNO_IRR_USE_NON_SYSTEM_LIB_PNG_ -DNOIRR_USE_NON_SYSTEM_JPEG_LIB_ to the compiler.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply