Cocos2d-x Android build won't find extensions - android

During running build_native.py i get error "ExtensionMacros.h" no such file or directory.
The file itself is in cocos2d\extensions. I edited android.mk and uncommented line resposnsible for including this file. Why wont it find it?
Here is my android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/extensions)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/Boxx.cpp \
../../Classes/World.cpp \
../../Classes/U.cpp \
../../Classes/CarrerWorld.cpp \
../../Classes/VisibleRect.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
# LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static
# LOCAL_WHOLE_STATIC_LIBRARIES += spine_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
$(call import-module,audio/android)
# $(call import-module,Box2D)
# $(call import-module,editor-support/cocosbuilder)
# $(call import-module,editor-support/spine)
# $(call import-module,editor-support/cocostudio)
# $(call import-module,network)
$(call import-module,extensions)
and the top of error source cpp file :
#include "World.h"
#include "U.h"
#include "Boxx.h"
#include "Globals.h"
#include "VisibleRect.h"
#include "extensions/cocos-ext.h" //<---- this file includes "extensionMacros.h"
USING_NS_CC;
USING_NS_CC_EXT;

Does cocos2d/extensions/Android.mk have the line?
LOCAL_C_INCLUDES := $(LOCAL_PATH)/..
https://github.com/cocos2d/cocos2d-x/blob/v3/extensions/Android.mk#L40
It needs to find the header file.

Related

arm-linux-androideabi-g++: error: CreateProcess: No such file or directory

first of all, I'm sorry for bad type English.
I want to compile an old source with NDK and cocos2d in windows.
this is my command line:
ndk-build NDK_DEBUG=1 -C "G:/coc/androiddev/dpsg_android/proj.android" "NDK_MODULE_PATH=G:/coc/androiddev/cocos2dx:G:/coc/androiddev/cocos2dx/platform/third_party/android/prebuilt"
and this is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := NativeRQD
LOCAL_SRC_FILES := prebuilt/armeabi/libNativeRQD.so
LOCAL_LDLIBS:= -L$(SYSROOT)/usr/lib -llog
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -DHAVE_CONFIG_H -D_GLIBCXX_PERMIT_BACKWARD_HASH -DCOCOS2D_DEBUG=1
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
FILE_LIST := $(LOCAL_PATH)/DPSGApp/main.cpp
FILE_LIST += $(wildcard $(LOCAL_PATH)/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/Common/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/NetWork/protobuf-2.4.1/src/google/protobuf/*.cc)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/NetWork/protobuf-2.4.1/src/google/protobuf/io/*.cc)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/NetWork/protobuf-2.4.1/src/google/protobuf/stubs/*.cc)
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/NetWork/snappy-1.0.5/snappy-sinksource.cc
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/NetWork/snappy-1.0.5/snappy-stubs-internal.cc
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/NetWork/snappy-1.0.5/snappy.cc
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/buffer.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/evbuffer.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/evdns.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/event.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/event_tagging.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/evutil.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/http.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/log.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/poll.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/epoll.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/select.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/signal.c
FILE_LIST += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/strlcpy.c
FILE_LIST += $(LOCAL_PATH)/../../../../rpc/proto/msg.pb.cc
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/Network/net/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/Graphics/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/GameFramework/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/Classes/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/Classes/GameLogic/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/Classes/GameCenter/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/Connections/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../client/dpsg/GAI/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../engine/src/Patcher/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../../engine/src/Patcher/7zDependencies/*.c)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../client/dpsg/Common
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/android
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Network/libevent-1.4.14b-stable/compat
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Network/net
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Network/protobuf-2.4.1
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Network/protobuf-2.4.1/src
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Network/snappy-1.0.5
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Network/src
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../rpc/proto
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/platform
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/platform/third_party/android/prebuilt
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/platform/third_party/android/prebuilt/libxml2/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/platform/android
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/cocoa
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/kazmath/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Graphics
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/extensions
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/shaders
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/support/zip_support
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/touch_dispatcher
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/cocos2dx/text_input_node
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/extensions/GUI/CCEditBox
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/extensions/GUI/CCControlExtension
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../androiddev/CocosDenshion/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/GameFramework
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Classes
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Classes/GameLogic
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Classes/GameCenter
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/Connections
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../client/dpsg/GAI
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../engine/src/Patcher
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-add-path, $(LOCAL_PATH)/../../../../androiddev)
$(call import-add-path, $(LOCAL_PATH)/../../../../androiddev/cocos2dx)
$(call import-add-path, $(LOCAL_PATH)/../../../../androiddev/CocosDenshion/android)
$(call import-add-path, $(LOCAL_PATH)/../../../../androiddev/cocos2dx/platform/third_party/android/prebuilt)
$(call import-module,cocos2dx)
$(call import-module,CocosDenshion/android)
$(call import-module,extensions)
first, everything is compiling good, but after a few minutes, I give "arm-linux-androideabi-g++: error: CreateProcess: No such file or directory" error.
I searched on google, stack overflow, cocos2d forum, but no any any any result.
I'm confused.
Check my image for more information:
http://imgur.com/a/GwCUT
Best Regards.

How can I merge two Android.mk files when adding a library?

I'm new with Android so I don't fully understand how to make Android.mk files.
My project was running fine, following a tutorial online where the Android.mk was provided. But later on I needed to add a missing library and the tutorial for that had another Android.mk, now I'm trying to merge the two together.
Here is my Android.mk :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#opencv
OPENCVROOT:= C:\OpenCV-2.4.10-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp
LOCAL_LDLIBS += -llog
LOCAL_MODULE := MyOpencvLibs
include $(BUILD_SHARED_LIBRARY)
Here is the Android.mk I need to add :
LOCAL_PATH := $(call my-dir)
OPENCV_PATH := D:/CODE/OpenCV-2.4.10-android-sdk/sdk/native/jni
include $(CLEAR_VARS)
LOCAL_MODULE := nonfree
LOCAL_SRC_FILES := libnonfree.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES := on
OPENCV_CAMERA_MODULES := off
include $(OPENCV_PATH)/OpenCV.mk
LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(OPENCV_PATH)/include
LOCAL_SRC_FILES := \
nonfree_jni.cpp
LOCAL_MODULE := nonfree_demo
LOCAL_CFLAGS := -Werror -O3 -ffast-math
LOCAL_LDLIBS := -llog -ldl
LOCAL_SHARED_LIBRARIES += nonfree
include $(BUILD_SHARED_LIBRARY)
What I'm interested in in the last Android.mk is the libnonfree.so only, I don't need the cpp file.
Here is the structure of my project :
EDIT :
Thanks for your answers. I've done what was suggested and my Android.mk looks like that now :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#opencv
OPENCVROOT:= C:\OpenCV-2.4.10-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp
LOCAL_LDLIBS += -llog
LOCAL_SHARED_LIBRARIES += nonfree
LOCAL_MODULE := MyOpencvLibs
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := nonfree
LOCAL_SRC_FILES := libnonfree.so
include $(PREBUILT_SHARED_LIBRARY)
But the problem remains. I've got "Undefined reference" to methods libnonfree.so should add. I assumed the problem was from the Android.mk but maybe it's from elsewhere then.
I've added System.loadLibrary("nonfree"); to my MainACtivity and
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/nonfree/features2d.hpp"
I don't know what I'm doing wrong.
EDIT 2 :
Here is the error :
Application.mk :
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16
I didn't know where to set arguments="V=1" in my build.gradle
My build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.adrien.ndkopencvtest4"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets.main {
//jniLibs.srcDirs = ['src/main/jniLibs']
jni.srcDirs = [] //disable automatic ndk-build call
}
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
commandLine "C:/Users/Adrien/AppData/Local/Android/sdk/ndk-bundle/ndk-build.cmd",
'NDK_PROJECT_PATH=build/intermediates/ndk',
'NDK_LIBS_OUT=src/main/jniLibs',
'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
'NDK_APPLICATION_MK=src/main/jni/Application.mk'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.github.wseemann:FFmpegMediaMetadataRetriever-armeabi-v7a:1.0.14'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile project(':openCVLibrary2410')
}
EDIT 3 :
Results of "ndk-build V=1" :
C:\Users\Adrien\AndroidStudioProjects\NDKOpencvTest4\app\src\main\jni>ndk-build V=1
[armeabi-v7a] SharedLibrary : libMyOpencvLibs.so
C:/Users/Adrien/AppData/Local/Android/sdk/ndk-bundle/build//../toolchains/llvm/preb
uilt/windows-x86_64/bin/clang++.exe -Wl,-soname,libMyOpencvLibs.so -shared --sysroo
t=C:/Users/Adrien/AppData/Local/Android/sdk/ndk-bundle/build//../platforms/android-
16/arch-arm C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/obj/l
ocal/armeabi-v7a/objs/MyOpencvLibs/com_example_adrien_ndkopencvtest4_OpencvNativeCl
ass.o C:/Users/Adrien/AppData/Local/Android/sdk/ndk-bundle/build//../sources/cxx-st
l/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a -lgcc C:/Users/Adrien/Andro
idStudioProjects/NDKOpencvTest4/app/src/main/obj/local/armeabi-v7a/libopencv_java.s
o C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/obj/local/armea
bi-v7a/libnonfree.so -gcc-toolchain C:/Users/Adrien/AppData/Local/Android/sdk/ndk-
bundle/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 -no-c
anonical-prefixes -target armv7-none-linux-androideabi -Wl,--fix-cortex-a8 -Wl,--b
uild-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-sh
ared-textrel -Wl,--fatal-warnings -LC:/Users/Adrien/AppData/Local/Android/sdk/ndk
-bundle/build//../platforms/android-16/arch-arm/usr/lib -llog -lc -lm -o C:/Users/A
drien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/obj/local/armeabi-v7a/libMy
OpencvLibs.so
C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/jni/com_example_a
drien_ndkopencvtest4_OpencvNativeClass.cpp:214: error: undefined reference to 'cv::
SURF::SURF(double, int, int, bool, bool)'
C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/jni/com_example_a
drien_ndkopencvtest4_OpencvNativeClass.cpp:222: error: undefined reference to 'cv::
SURF::SURF()'
C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/jni/com_example_a
drien_ndkopencvtest4_OpencvNativeClass.cpp:204: error: undefined reference to 'VTT
for cv::SURF'
C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/jni/com_example_a
drien_ndkopencvtest4_OpencvNativeClass.cpp:204: error: undefined reference to 'VTT
for cv::SURF'
C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/jni/com_example_a
C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/jni/com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp:204: error: undefined
reference to 'VTT for cv::SURF'
C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/jni/com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp:449: error: undefined
reference to 'cv::SURF::SURF(double, int, int, bool, bool)'
C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/jni/com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp:457: error: undefined
reference to 'cv::SURF::SURF()'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [C:/Users/Adrien/AndroidStudioProjects/NDKOpencvTest4/app/src/main/obj/local/armeabi-v7a/libMyOpencvLibs.so] Error 1
SOLUTION :
My libnonfree.so file was not correct, I downloaded another one. I also changed my Application.mk file to :
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16
If you want to add a prebuilt shared library to your project, you don't need a separate Android.mk
Let's take your script,
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#opencv
OPENCVROOT:= C:\OpenCV-2.4.10-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp
LOCAL_LDLIBS += -llog
LOCAL_MODULE := MyOpencvLibs
include $(BUILD_SHARED_LIBRARY)
and simply add to the bottom the extra module you need:
include $(CLEAR_VARS)
LOCAL_MODULE := nonfree
LOCAL_SRC_FILES := libnonfree.so
include $(PREBUILT_SHARED_LIBRARY)
Now the file C:\Users\Adrien\AndroidStudioProjects\NDKOpencvTest4\app\src\main\jni\libnonfree.so will be packed into your APK.
If you need this library to link your libMyOpencvLibs.so (this means, if your code in com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp uses some functions exported from libnonfree.so, you should also refeence it in your module:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#opencv
OPENCVROOT:= C:\OpenCV-2.4.10-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp
LOCAL_LDLIBS += -llog
LOCAL_SHARED_LIBRARIES += nonfree
LOCAL_MODULE := MyOpencvLibs
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := nonfree
LOCAL_SRC_FILES := libnonfree.so
include $(PREBUILT_SHARED_LIBRARY)
Modify your android.mk as:
LOCAL_PATH := $(call my-dir)
OPENCV_PATH := D:/CODE/OpenCV-2.4.10-android-sdk/sdk/native/jni
include $(CLEAR_VARS)
LOCAL_MODULE := nonfree
LOCAL_SRC_FILES := libnonfree.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
#opencv
OPENCVROOT:= C:\OpenCV-2.4.10-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp
LOCAL_SHARED_LIBRARIES += nonfree
LOCAL_LDLIBS += -llog
LOCAL_MODULE := MyOpencvLibs
include $(BUILD_SHARED_LIBRARY)
Here the prebuild library i.e. libnonfree.so is declared in the android.mk, and referenced to it later via
LOCAL_SHARED_LIBRARIES += nonfree
Now to use it you need to load the latest built library in yout MainActivity i.e.
System.loadLibrary("MyOpencvLibs");
Thats it, now you have merged both the android.mk files into a new module named: MyOpencvLibs
For better understanding you can read my blog : https://androidtutsweb.wordpress.com/2017/04/04/android-mk-for-ndk-build-using-pre-build-libraries/

Including SDL headers on android studio

I m new to SDL, i have a problem to compile my project example i have:
#include "SDL_config.h" //(in red)
if i change it to:
#include "../include/SDL_config.h" //(it became green)
Also i have multiple Anroid.mk files like below, Is there some thing missing in Android.mk files to avoid rewriting all the project headers?
src\Anroid.mk :
LOCAL_PATH := $(call my-dir)
MY_PATH := $(LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_PATH := $(MY_PATH)
include $(LOCAL_PATH)/android/Android.include
include $(LOCAL_PATH)/burn/Android.mk
include $(LOCAL_PATH)/burner/Android.mk
include $(LOCAL_PATH)/cpu/Android.mk
include $(LOCAL_PATH)/dep/libs/lib7z/Android.mk
include $(LOCAL_PATH)/dep/libs/libpng/Android.mk
LOCAL_MODULE := arcade
LOCAL_ARM_MODE := arm
ANDROID_OBJS := android/android.cpp android/android_main.cpp android/android_run.cpp \
android/android_softfx.cpp android/android_sdlfx.cpp \
android/android_input.cpp android/android_snd.cpp \
android/android_stated.cpp
INTF_DIR := $(LOCAL_PATH)/intf
INTF_OBJS := $(wildcard $(INTF_DIR)/*.cpp)
INTF_AUDIO_DIR := $(LOCAL_PATH)/intf/audio
INTF_AUDIO_OBJS := $(wildcard $(INTF_AUDIO_DIR)/*.cpp)
INTF_AUDIO_SDL_DIR := $(LOCAL_PATH)/intf/audio/sdl
INTF_AUDIO_SDL_OBJS := $(wildcard $(INTF_AUDIO_SDL_DIR)/*.cpp)
INTF_INPUT_DIR := $(LOCAL_PATH)/intf/input
INTF_INPUT_OBJS := $(wildcard $(INTF_INPUT_DIR)/*.cpp)
INTF_INPUT_SDL_DIR := $(LOCAL_PATH)/intf/input/sdl
INTF_INPUT_SDL_OBJS := $(wildcard $(INTF_INPUT_SDL_DIR)/*.cpp)
INTF_VIDEO_DIR := $(LOCAL_PATH)/intf/video
INTF_VIDEO_OBJS := $(wildcard $(INTF_VIDEO_DIR)/*.cpp)
INTF_VIDEO_SDL_DIR := $(LOCAL_PATH)/intf/video/sdl
INTF_VIDEO_SDL_OBJS := $(wildcard $(INTF_VIDEO_SDL_DIR)/*.cpp)
LOCAL_SRC_FILES += $(ANDROID_OBJS) \
$(LIB7Z) $(LIBPNG) $(BURN) $(BURNER) $(CPU) \
$(subst jni/src/,,$(INTF_OBJS)) \
$(subst jni/src/,,$(INTF_AUDIO_OBJS)) \
$(subst jni/src/,,$(INTF_AUDIO_SDL_OBJS)) \
$(subst jni/src/,,$(INTF_INPUT_OBJS)) \
$(subst jni/src/,,$(INTF_INPUT_SDL_OBJS)) \
$(subst jni/src/,,$(INTF_VIDEO_OBJS)) \
$(subst jni/src/,,$(INTF_VIDEO_SDL_OBJS))
#$(warning $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out intf/input/sdl/inp_sdl.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out intf/video/vid_softfx.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out intf/video/sdl/vid_sdlopengl.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out intf/video/sdl/vid_sdlfx.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out intf/audio/sdl/aud_sdl.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out intf/audio/aud_interface.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out burner/sdl/main.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out burner/sdl/run.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out burner/sdl/stated.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out burn/drv/pgm/pgm_sprite_create.cpp, $(LOCAL_SRC_FILES))
LOCAL_SRC_FILES := $(filter-out cpu/mips3_intf.cpp, $(LOCAL_SRC_FILES))
LOCAL_STATIC_LIBRARIES := minizip
LOCAL_SHARED_LIBRARIES := SDL
LOCAL_LDLIBS := -lGLESv1_CM -llog -lz
include $(BUILD_SHARED_LIBRARY)
SDL\Anroid.mk :
LOCAL_PATH := $(call my-dir)
###########################
#
# SDL shared library
#
###########################
include $(CLEAR_VARS)
LOCAL_MODULE := SDL
LOCAL_ARM_MODE := arm
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_CFLAGS += -D GL_GLEXT_PROTOTYPES -DHAVE_STDIO_H
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CFLAGS += -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3 -O3 -Os
endif
LOCAL_SRC_FILES := \
$(subst $(LOCAL_PATH)/,, \
$(wildcard $(LOCAL_PATH)/src/*.c) \
$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
$(wildcard $(LOCAL_PATH)/src/core/android/*.cpp) \
$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
$(wildcard $(LOCAL_PATH)/src/events/*.c) \
$(wildcard $(LOCAL_PATH)/src/file/*.c) \
$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
$(wildcard $(LOCAL_PATH)/src/power/*.c) \
$(wildcard $(LOCAL_PATH)/src/render/*.c) \
$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
$(wildcard $(LOCAL_PATH)/src/video/*.c) \
$(wildcard $(LOCAL_PATH)/src/video/android/*.c))
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog
include $(BUILD_SHARED_LIBRARY)

how to call a c function in the C++ function with the same name?

how to call a c function in the C++ function with the same name?
calling 'extern "c"' to use c header and "::"operation to use the c function,
but the link error occur.
my code:
extern "C" {
#include <libavcodec/avcodec.h>
}
...
class DllAvCodec
{
public:
...
virtual void av_free_packet(AVPacket *pkt) { ::av_free_packet(pkt); }
...
}
the error:
D:/player/jni/lib/DllAvCodec.h:143: error: undefined reference to 'av_free_packet(AVPacket*)'
why the code "::av_free_packet(pkt)" invoke undefined?
my Android.mk is :
LOCAL_PATH := $(call my-dir)
DEFINES += \
-DTARGET_POSIX \
-DTARGET_LINUX \
-D_LINUX \
-DTARGET_ANDROID \
-D__STDC_CONSTANT_MACROS
######################################
#build ffmpeg prebuilt lib
######################################
include $(CLEAR_VARS)
LOCAL_MODULE := libavcodec
LOCAL_SRC_FILES := lib/lib/libavcodec.a
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libavfilter
LOCAL_SRC_FILES := lib/lib/libavfilter.a
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libavformat
LOCAL_SRC_FILES := lib/lib/libavformat.a
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libavutil
LOCAL_SRC_FILES := lib/lib/libavutil.a
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libpostproc
LOCAL_SRC_FILES := lib/lib/libpostproc.a
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libswresample
LOCAL_SRC_FILES := lib/lib/libswresample.a
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libswscale
LOCAL_SRC_FILES := lib/lib/libswscale.a
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)
######################################
#build lib
######################################
include $(CLEAR_VARS)
LOCAL_MODULE:= player
base := $(LOCAL_PATH)
LOCAL_SRC_FILES += ......
LOCAL_CPPFLAGS += -Wall -fexceptions $(DEFINES)
LOCAL_LDLIBS += -llog -lz
LOCAL_LDFLAGS += -L../jni/lib/lib -lavcodec -lavformat -lavutil -lavfilter -lpostproc -lswscale -lswresample
LOCAL_STATIC_LIBRARIES := libavcodec \
libavformat \
libavutil \
libavfilter \
libpostproc \
libswscale \
libswresample
include $(BUILD_SHARED_LIBRARY)

Problems compiling VLC for Android - libvlcjni.so

After a day and a half of modification I've finally gotten the VLC project to almost compile under OS X. I get the following error when its just about to link libvlcjni.so. There are roughly 100 more undefined references, but most are to few functions:
std::__stl_throw_length_error(char const*)
std::__node_alloc::_M_deallocate(void*, unsigned int)
Has anyone got any pointers?
Compile thumb : vlcjni <= aout.c
Compile thumb : vlcjni <= pthread-condattr.c
Compile thumb : vlcjni <= pthread-rwlocks.c
Compile thumb : vlcjni <= eventfd.c
Compile thumb : vlcjni <= sem.c
SharedLibrary : libvlcjni.so
../vlc/android/modules/demux/mkv/.libs/libmkv_plugin.a(libmkv_plugin_la-mkv.o): In function std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_compare(char const*, char const*, char const*, char const*)':
/Android/ndk/sources/cxx-stl/stlport/stlport/stl/_string.h:1076: undefined reference tostd::__stl_throw_out_of_range(char const*)'
Application.mk
APP_PLATFORM := android-9
ifeq ($(NO_NEON),)
APP_ABI := armeabi-v7a
else ifneq ($(TEGRA2),)
APP_ABI := armeabi-v7a
else
APP_ABI := armeabi
endif
APP_STL := gnustl_static
APP_PLATFORM := android-9
APP_ABI := armeabi-v7a
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifeq ($(NO_NEON),)
ARCH=armeabi-v7a
LOCAL_MODULE := libvlcjni
else ifneq ($(TEGRA2),)
ARCH=armeabi-v7a
LOCAL_MODULE := libvlcjni-tegra2
else
ARCH=armeabi
LOCAL_MODULE := libvlcjni
endif
LOCAL_SRC_FILES := libvlcjni_danmaku.c aout.c pthread-condattr.c pthread-rwlocks.c eventfd.c sem.c
LOCAL_C_INCLUDES := $(VLC_SRC_DIR)/include
ifeq ($(NO_NDK_V7),1)
CPP_STATIC=$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/libs/$(ARCH)/libstdc++.a
else
CPP_STATIC=$(ANDROID_NDK)/sources/cxx-stl/stlport/libs/$(ARCH)/libstlport_static.a
endif
LOCAL_CFLAGS := -std=gnu99
LOCAL_LDLIBS := -L$(VLC_CONTRIB)/lib \
$(VLC_MODULES) \
$(VLC_BUILD_DIR)/lib/.libs/libvlc.a \
$(VLC_BUILD_DIR)/src/.libs/libvlccore.a \
$(VLC_BUILD_DIR)/compat/.libs/libcompat.a \
-ldl -lz -lm -llog \
-ldvbpsi -lebml -lmatroska -ltag \
-logg -lFLAC -ltheora \
-lmpeg2 -ldca -la52 \
-lavformat -lavcodec -lswscale -lavutil -lpostproc -lgsm -lopenjpeg \
-lliveMedia -lUsageEnvironment -lBasicUsageEnvironment -lgroupsock \
-lspeex -lspeexdsp \
-lxml2 -lpng -lgnutls -lgcrypt -lgpg-error -lfreetype -liconv \
$(CPP_STATIC)
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libiomx-gingerbread
LOCAL_SRC_FILES := ../$(VLC_SRC_DIR)/modules/codec/omxil/iomx.cpp
LOCAL_C_INCLUDES := $(VLC_SRC_DIR)/modules/codec/omxil $(ANDROID_SYS_HEADERS_GINGERBREAD)/frameworks/base/include $(ANDROID_SYS_HEADERS_GINGERBREAD)/system/core/include
LOCAL_LDLIBS := -L$(ANDROID_LIBS) -lgcc -lstagefright -lmedia -lutils -lbinder
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libiomx-hc
LOCAL_SRC_FILES := ../$(VLC_SRC_DIR)/modules/codec/omxil/iomx.cpp
LOCAL_C_INCLUDES := $(VLC_SRC_DIR)/modules/codec/omxil $(ANDROID_SYS_HEADERS_HC)/frameworks/base/include $(ANDROID_SYS_HEADERS_HC)/frameworks/base/native/include $(ANDROID_SYS_HEADERS_HC)/system/core/include $(ANDROID_SYS_HEADERS_HC)/hardware/libhardware/include
LOCAL_LDLIBS := -L$(ANDROID_LIBS) -lgcc -lstagefright -lmedia -lutils -lbinder
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libiomx-ics
LOCAL_SRC_FILES := ../$(VLC_SRC_DIR)/modules/codec/omxil/iomx.cpp
LOCAL_C_INCLUDES := $(VLC_SRC_DIR)/modules/codec/omxil $(ANDROID_SYS_HEADERS_ICS)/frameworks/base/include $(ANDROID_SYS_HEADERS_ICS)/frameworks/base/native/include $(ANDROID_SYS_HEADERS_ICS)/system/core/include $(ANDROID_SYS_HEADERS_ICS)/hardware/libhardware/include
LOCAL_LDLIBS := -L$(ANDROID_LIBS) -lgcc -lstagefright -lmedia -lutils -lbinder
include $(BUILD_SHARED_LIBRARY)
Try to include these lines into your Application.mk:
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
You have to explicitly enable the RTTI and Exceptions handling.
EDIT (response to your modifications):
# These are your lines in Application.mk
APP_PLATFORM := android-9
ifeq ($(NO_NEON),)
APP_ABI := armeabi-v7a
else ifneq ($(TEGRA2),)
APP_ABI := armeabi-v7a
else
APP_ABI := armeabi
endif
# Add these lines:
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
# I haven't seen them

Categories

Resources