linking prebuild lib for every instruction set NDK - c++

EDIT: I would like to linking prebuild lib, but i dont know how to call this fftw3.libs from obj...folder, for every instructions sets: I have to use if condtioiton for every ?
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := fftw3_mod
LOCAL_SRC_FILES:= libfftw3_mod.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := com_jp_algi_CoreC
LOCAL_SRC_FILES := After.cpp com_jp_algi_CoreC.cpp FFTReal.cpp
LOCAL_C_INCLUDES := /FileBroswer/jni/Eigen
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CPPFLAGS := -mfpu=neon -mfloat-abi=softfp
LOCAL_ARM_NEON := true
endif
include $(BUILD_SHARED_LIBRARY)

The easiest approach is to puf the prebuilt libs in subfolders armeabi, x86, etc.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := fftw3_mod
LOCAL_SRC_FILES:= $(TARGET_ARCH_ABI)/libfftw3_mod.a
include $(PREBUILT_STATIC_LIBRARY)

Related

including header files from prebuilt library Android.mk

I have included a prebuilt library into my library creation using
include $(PREBUILT_SHARED_LIBRARY)
and verified weather library is included or not by using
$(modules-get-list)
When i try to include a header file present within prebuilt library, i face error header not found. Below is my exact Android.mk file
LOCAL_PATH := $(call my-dir)
# import prebuilt-library
include $(CLEAR_VARS)
LOCAL_MODULE := prebuilt-library
LOCAL_SRC_FILES := ../../../target/dependency/libs/$(TARGET_ARCH_ABI)/libprebuilt.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
# building provider interface library for communication
include $(CLEAR_VARS)
LOCAL_MODULE := library-interface
LOCAL_SRC_FILES := LibraryComminicator.cpp
LOCAL_SHARED_LIBRARIES := prebuilt-library
include $(BUILD_SHARED_LIBRARY)
$(warning Existing modules: "$(modules-get-list)")
# Include the Android Maven plugin generated makefile
# Important: Must be the last import in order for Android Maven Plugins paths to work
include $(ANDROID_MAVEN_PLUGIN_MAKEFILE)
Try the Android.mk below:
LOCAL_PATH := $(call my-dir)
EXT_LIB_ROOT := $(LOCAL_PATH)/../../../target/dependency # or whatever
# building provider interface library for communication
include $(CLEAR_VARS)
LOCAL_MODULE := library-interface
LOCAL_SRC_FILES := LibraryComminicator.cpp
LOCAL_SHARED_LIBRARIES := prebuilt-library
include $(BUILD_SHARED_LIBRARY)
# import prebuilt-library
LOCAL_PATH := $(EXT_LIB_ROOT)
include $(CLEAR_VARS)
LOCAL_MODULE := prebuilt-library
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libprebuilt.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
$(warning Existing modules: "$(modules-get-list)")
The basic rules are: xxx_INCLUDE_FILES should be relative to 'current dir', while LOCAL_SRC_FILES are relative to $(LOCAL_PATH), not to the 'current dir'. With NDK, typically the 'current dir' is $(LOCAL_PATH)/.. but this could change, especially if Android.mk files are linked, i.e. one includes another.
And you really don't need LOCAL_PATH for PREBUILT_SHARED_LIBRARY modules, but I prefer to keep LOCAL_SRC_FILES as short as possible.

Android ndk compiling error: unknown type name 'JNIEnv'

I am coding in Android studio, would make a .so file . But I cannot resolve this problem . Though I have included who can help me?
My jni folder and error info img :
http://i.stack.imgur.com/Ankmm.png
My Android.mk file:
include $(CLEAR_VARS)
LOCAL_MODULE := swresample-prebuilt
LOCAL_SRC_FILES := $(LOCAL_PATH)/../../libs/libswresample-2.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libswresample include
$(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpegplay
LOCAL_SRC_FILES := NativeUtil.c FFmpegCodec.c
LOCAL_LDLIBS :=-llog
LOCAL_SHARED_LIBRARIES := avcodec-prebuilt avformat-prebuilt swscale-prebuilt avutil-prebuilt swresample-prebuilt
LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS
include $(BUILD_SHARED_LIBRARY)

Android NDK: undefined reference

I am trying to develop an application for android using VTK for android.
I have compile all the sources so far everything have worked just fine.
Now I'm stuck here, an undefined reference error which is:
Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in /Users/lonnibesancon/Documents/workspace/TestNativecopy/AndroidManifest.xml
[armeabi-v7a] Compile++ thumb: ndk1 <= native.cxx
[armeabi-v7a] Compile thumb : android_native_app_glue <= android_native_app_glue.c
[armeabi-v7a] StaticLibrary : libandroid_native_app_glue.a
[armeabi-v7a] SharedLibrary : libndk1.so
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkRenderWindow::New()'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkRenderer::New()'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkAndroidRenderWindowInteractor::New()'
/Users/lonnibesancon/Documents/workspace/TestNativecopy/jni/native.cxx:61: error: undefined reference to 'vtkRenderWindowInteractor::SetRenderWindow(vtkRenderWindow*)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkSphereSource::New()'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkPolyDataMapper::New()'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkAlgorithm.h:391: error: undefined reference to 'vtkAlgorithm::GetOutputPort(int)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkActor::New()'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkConeSource::New()'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkGlyph3D::New()'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkAlgorithm.h:391: error: undefined reference to 'vtkAlgorithm::GetOutputPort(int)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkAlgorithm.h:391: error: undefined reference to 'vtkAlgorithm::GetOutputPort(int)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkGlyph3D.h:131: error: undefined reference to 'vtkGlyph3D::SetSourceConnection(int, vtkAlgorithmOutput*)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkPolyDataMapper::New()'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkAlgorithm.h:391: error: undefined reference to 'vtkAlgorithm::GetOutputPort(int)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkNew.h:66: error: undefined reference to 'vtkActor::New()'
/Users/lonnibesancon/Documents/workspace/TestNativecopy/jni/native.cxx:88: error: undefined reference to 'vtkRenderer::AddActor(vtkProp*)'
/Users/lonnibesancon/Documents/workspace/TestNativecopy/jni/native.cxx:89: error: undefined reference to 'vtkRenderer::AddActor(vtkProp*)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkDebugLeaksManager.h:39: error: undefined reference to 'vtkDebugLeaksManager::vtkDebugLeaksManager()'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkDebugLeaksManager.h:39: error: undefined reference to 'vtkDebugLeaksManager::~vtkDebugLeaksManager()'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:190: error: undefined reference to 'AInputQueue_getEvent'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:192: error: undefined reference to 'AInputQueue_preDispatchEvent'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:197: error: undefined reference to 'AInputQueue_finishEvent'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:211: error: undefined reference to 'AConfiguration_new'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:212: error: undefined reference to 'AConfiguration_fromAssetManager'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:66: error: undefined reference to 'AConfiguration_getLanguage'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:67: error: undefined reference to 'AConfiguration_getCountry'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:223: error: undefined reference to 'ALooper_prepare'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:224: error: undefined reference to 'ALooper_addFd'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:179: error: undefined reference to 'AInputQueue_detachLooper'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:181: error: undefined reference to 'AConfiguration_delete'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:95: error: undefined reference to 'AInputQueue_detachLooper'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:100: error: undefined reference to 'AInputQueue_attachLooper'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:134: error: undefined reference to 'AConfiguration_fromAssetManager'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:66: error: undefined reference to 'AConfiguration_getLanguage'
/Users/lonnibesancon/android-ndk-r10e/sources/android/native_app_glue/android_native_app_glue.c:67: error: undefined reference to 'AConfiguration_getCountry'
collect2: error: ld returned 1 exit status
make: *** [/Users/lonnibesancon/Documents/workspace/TestNativecopy/obj/local/armeabi-v7a/libndk1.so] Error 1
The content of my android.mk file is the following:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# VTK Libs
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkalglib-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkalglib-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkCommonColor-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkCommonColor-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkCommonComputationalGeometry-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkCommonComputationalGeometry-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkCommonCore-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkCommonCore-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkCommonMath-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkCommonMath-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkCommonMisc-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkCommonMisc-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkCommonSystem-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkCommonSystem-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkCommonTransforms-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkCommonTransforms-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkDICOMParser-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkDICOMParser-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkexpat-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkexpat-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkFiltersCore-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkFiltersCore-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkFiltersExtraction-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkFiltersExtraction-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkFiltersGeneral-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkFiltersGeneral-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkFiltersGeometry-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkFiltersGeometry-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkFiltersModeling-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkFiltersModeling-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkFiltersSources-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkFiltersSources-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkFiltersStatistics-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkFiltersStatistics-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkglew-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkglew-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkImagingCore-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkImagingCore-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkImagingFourier-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkImagingFourier-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkImagingHybrid-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkImagingHybrid-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkInfovisCore-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkInfovisCore-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkInteractionStyle-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkInteractionStyle-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkIOCore-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkIOCore-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkIOGeometry-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkIOGeometry-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkIOImage-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkIOImage-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkIOInfovis-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkIOInfovis-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkIOLegacy-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkIOLegacy-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkIOPLY-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkIOPLY-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkIOXML-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkIOXML-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkIOXMLParser-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkIOXMLParser-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkjpeg-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkjpeg-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkjsoncpp-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkjsoncpp-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtklibxml2-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtklibxml2-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkmetaio-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkmetaio-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkParallelCore-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkParallelCore-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkpng-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkpng-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkRenderingCore-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkRenderingCore-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkRenderingOpenGL2-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkRenderingOpenGL2-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtksys-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtksys-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtktiff-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtktiff-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libvtkzlib-6.3
LOCAL_SRC_FILES = /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/lib/libvtkzlib-6.3.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/alglib/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkexpat/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkglew/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkjpeg/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkjsoncpp/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtklibxml2/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkmetaio/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkpng/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtksys/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtktiff/
LOCAL_C_INCLUDES += /Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkzlib/
LOCAL_STATIC_LIBRARIES := cpufeatures android_native_app_glue ndk_helper
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_CPPFLAGS += --std=c++11
LOCAL_LDLIBS := -llog
LOCAL_MODULE := ndk1
LOCAL_SRC_FILES := native.cxx
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
It might be a really dumb error (still a newbie) but I would like some help here if possible.
EDIT: As suggested in some posts here, I have tried LOCAL_ALLOW_UNDEFINED_SYMBOLS:=true
but what it does is just ignore the problem until runtime and when I try to run the application returns with error directly like this one:
dlopen("/data/app-lib/com.example.vtknative-2/libndk1.so") failed: dlopen failed: cannot locate symbol
"_ZN32vtkAndroidRenderWindowInteractor14HandleKeyEventEbiii" referenced by "libndk1.so"...
EDIT2: as suggested by #samgak I added the prebuilt static libraries to my LOCAL_STATIC_LIBRARIES list.
Yet the first error I get is:
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkAlgorithm.h:391: error: undefined reference to 'vtkAlgorithm::GetOutputPort(int)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkAlgorithm.h:391: error: undefined reference to 'vtkAlgorithm::GetOutputPort(int)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkAlgorithm.h:391: error: undefined reference to 'vtkAlgorithm::GetOutputPort(int)'
/Users/lonnibesancon/Desktop/VTK/build4/CMakeExternals/Install/vtk-android/include/vtk-6.3/vtkAlgorithm.h:391: error: undefined reference to 'vtkAlgorithm::GetOutputPort(int)'
And here is the corresponding line in the vtkAlgorithm.h (lines 389,390 and 391)
vtkAlgorithmOutput* GetOutputPort(int index);
vtkAlgorithmOutput* GetOutputPort() {
return this->GetOutputPort(0); }
Add your prebuilt static libraries to your LOCAL_STATIC_LIBRARIES list:
LOCAL_STATIC_LIBRARIES := cpufeatures android_native_app_glue ndk_helper \
libvtkalglib-6.3 \
libvtkCommonColor-6.3 \
libvtkCommonComputationalGeometry-6.3 \
libvtkCommonCore-6.3 \
libvtkCommonMath-6.3 \
libvtkCommonMisc-6.3 \
libvtkCommonSystem-6.3 \
libvtkCommonTransforms-6.3 \
libvtkDICOMParser-6.3 \
libvtkexpat-6.3 \
libvtkFiltersCore-6.3 \
libvtkFiltersExtraction-6.3 \
libvtkFiltersGeneral-6.3 \
libvtkFiltersGeometry-6.3 \
libvtkFiltersModeling-6.3 \
libvtkFiltersSources-6.3 \
libvtkFiltersStatistics-6.3 \
libvtkglew-6.3 \
libvtkImagingCore-6.3 \
libvtkImagingFourier-6.3 \
libvtkImagingHybrid-6.3 \
libvtkInfovisCore-6.3 \
libvtkInteractionStyle-6.3 \
libvtkIOCore-6.3 \
libvtkIOGeometry-6.3 \
libvtkIOImage-6.3 \
libvtkIOInfovis-6.3 \
libvtkIOLegacy-6.3 \
libvtkIOPLY-6.3 \
libvtkIOXML-6.3 \
libvtkIOXMLParser-6.3 \
libvtkjpeg-6.3 \
libvtkjsoncpp-6.3 \
libvtklibxml2-6.3 \
libvtkmetaio-6.3 \
libvtkParallelCore-6.3 \
libvtkpng-6.3 \
libvtkRenderingCore-6.3 \
libvtkRenderingOpenGL2-6.3 \
libvtksys-6.3 \
libvtktiff-6.3 \
libvtkzlib-6.3
It would seem that this Android.mk just did the job. I also post the Application.mk just in case, it may help others too.
It seems that I was not linking correctly. The way we did simply does not work while I do not get any errors when using the following files.
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ndk1
# Recursive wildcard in pure make, no external commands required
# From: http://stackoverflow.com/a/12959764
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
# Recursively find all *.cpp files under LOCAL_PATH
LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(call rwildcard,$(LOCAL_PATH),*.cpp))
# Compiler flags
# LOCAL_CFLAGS += -Ofast -Wall -Wextra -pedantic -Wno-unused-parameter -DNDEBUG
LOCAL_CFLAGS += -Ofast -Wall -Wextra -pedantic -Wno-unused-parameter -UNDEBUG
# LOCAL_CFLAGS += -O0 -g -Wall -Wextra -pedantic -Wno-unused-parameter
# (optional) Silence warnings in the NDK headers
LOCAL_CFLAGS += -isystem ${NDK_ROOT}/platforms/$(TARGET_PLATFORM)/arch-arm/usr/include
# Enable NEON instructions
LOCAL_ARM_NEON := true
# Use the more efficient 32-bit instructions, at the expense
# of a larger code size
LOCAL_ARM_MODE := arm
# Logging library (__android_log_* functions)
LOCAL_LDLIBS += -llog
# OpenGL ES 2.0
LOCAL_LDLIBS += -lGLESv2
# LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
LOCAL_LDFLAGS += -L /Users/lonnibesancon/Desktop/VTK/buildandroid2/CMakeExternals/Build/vtk-android/lib/
# NOTE: the link order is important!
LOCAL_LDFLAGS += -lvtkIOXML-6.3 -lvtkIOLegacy-6.3 -lvtkIOPLY-6.3 -lvtkIOGeometry-6.3 -lvtkFiltersModeling-6.3 -lvtkImagingCore-6.3 -lvtkRenderingCore-6.3 -lvtkIOImage-6.3 -lvtkDICOMParser-6.3 -lvtkmetaio-6.3 -lvtkpng-6.3 -lvtktiff-6.3 -lvtkjpeg-6.3 -lvtkFiltersSources-6.3 -lvtkFiltersGeometry-6.3 -lvtkIOXMLParser-6.3 -lvtkIOCore-6.3 -lvtkexpat-6.3 -lvtkFiltersExtraction-6.3 -lvtkFiltersGeneral-6.3 -lvtkFiltersCore-6.3 -lvtkCommonExecutionModel-6.3 -lvtkCommonComputationalGeometry-6.3 -lvtkCommonDataModel-6.3 -lvtkCommonMisc-6.3 -lvtkCommonTransforms-6.3 -lvtkCommonSystem-6.3 -lvtkCommonMath-6.3 -lvtkCommonCore-6.3 -lvtksys-6.3 -lvtkzlib-6.3
#notfound : -lvtkRenderingFreeType-6.3
# Use -isystem to silence warnings in the VES headers
#LOCAL_CFLAGS += -isystem $(LOCAL_PATH)/../../thirdparty/VES/Apps/Android/CMakeBuild/build/CMakeExternals/Install/eigen
#LOCAL_CFLAGS += -isystem $(LOCAL_PATH)/../../thirdparty/VES/Apps/Android/CMakeBuild/build/CMakeExternals/Install/vtk-android/include/vtk-6.3/
# LOCAL_C_INCLUDES += ${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.6/include
# LOCAL_C_INCLUDES += ${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include
#LOCAL_SHARED_LIBRARIES := artoolkit
# LOCAL_SHARED_LIBRARIES := artoolkitplus
include $(BUILD_SHARED_LIBRARY)
Application.mk:
APP_ABI := armeabi-v7a
APP_STL := gnustl_shared
GCC_ENABLE_CPP_RTTI := YES
# Set target Android API level to the application's minimum SDK version.
APP_PLATFORM := android-14
It builds just fine even though I still get some warnings about the android version and the shared librairies.

Android NDK -Linker errors to shared libraries.

I'm trying to figure out why I keep getting undefined references to functions that are declared in shared libraries that come with android.
My application.mk and root android.mk
APP_MODULES := adhoc
APP_STL := gnustl_shared
NDK_TOOLCHAIN_VERSION=clang3.1
APP_OPTIM := debug
CUR_PATH := $(call my-dir)
LOCAL_CPPFLAGS += -std-c++11 -Wwrite-strings
include $(CUR_PATH)/native/adhoc/Android.mk
adhoc Android.mk
LOCAL_PATH := $(call my-dir)
updater_src_files := \
install.cpp\
sha1.cpp\
addhoc_lib.cpp
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(updater_src_files)
inc_path = $(NDK_ROOT)/../AndroidSource/system/core/include \
$(NDK_ROOT)/../AndroidSource/hardware/libhardware_legacy/include
LOCAL_C_INCLUDES += $(inc_path)
LOCAL_CFLAGS := -DINTERNAL_SHA1 -DCONFIG_CRYPTO_INTERNAL -DCONFIG_NO_T_PRF -DCONFIG_NO_TLS_PRF -std=c++11 -Wc++11-extensions -Wno-deprecated-writable-strings
LOCAL_STATIC_LIBRARIES := libedify
LOCAL_SHARED_LIBRARIES := libcutils\
libhardware_legacy\
libc\
libnetutils\
libsysutils
LOCAL_MODULE := adhoc
include $(BUILD_SHARED_LIBRARY)
$(call import-add-path, $(LOCAL_PATH))
$(call import-module, edify)
and adhoc/edify/android.mk
LOCAL_PATH := $(call my-dir)
edify_src_files := \
lexer.l \
parser.y \
expr.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(edify_src_files)
LOCAL_CFLAGS := $(edify_cflags)
LOCAL_MODULE := edify
include $(BUILD_STATIC_LIBRARY)
I get output from ndk-build -B V=1 like:
SharedLibrary : libadhoc.so
/home/corey/Android_Dev/android-ndk-r8d/toolchains/llvm-3.1/prebuilt/linux-x86/bin/clang++ -Wl,-soname,libadhoc.so -shared --sysroot=/home/corey/Android_Dev/android-ndk-r8d/platforms/android-14/arch-arm ./obj/local/armeabi/objs-debug/adhoc/install.o ./obj/local/armeabi/objs-debug/adhoc/sha1.o ./obj/local/armeabi/objs-debug/adhoc/addhoc_lib.o ./obj/local/armeabi/libedify.a ./obj/local/armeabi/libgnustl_shared.so -gcc-toolchain /home/corey/Android_Dev/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86 -no-canonical-prefixes -target armv5te-none-linux-androideabi -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now /home/corey/Android_Dev/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libsupc++.a -lc -lm -o ./obj/local/armeabi/libadhoc.so
/home/corey/Android_Dev/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs-debug/adhoc/install.o: in function GetPropFn(char const*, State*, int, Expr**):jni/native/adhoc/install.cpp:463: error: undefined reference to 'property_get'
If you are using C++ code, then add C PLUS PLUS flag.
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
Also take a look at the following post.
android ndk undefined reference to a method

how to write Android.mk files for multi-libs native c project?

I have a seGraphics lib ,it deps agg lib and freetype lib.All of them are source files
I want to generate one seGraphics.a file.
Should i write a Android.mk file for each? How to write it?
TIA!
Here is my wrong try:
#Android.mk for seGraphics
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../../Agg/Android.mk
LOCAL_CXXFLAGS := -I../../
LOCAL_MODULE := seGraphics
LOCAL_SRC_FILES := ../../seCommonGradientBrush.cpp ../../seHatchBrush.cpp
LOCAL_CPP_EXTENSION := .cpp
include $(BUILD_STATIC_LIBRARY)
.
#Android.mk for agg
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := agg
LOCAL_LDFLAGS :=
LOCAL_CFLAGS := -O3
LOCAL_C_INCLUDES := /home/maadiah/android-ndk-r6/platforms/android-9/arch-arm/usr/include \
$(LOCAL_PATH)/font_freetype \
$(LOCAL_PATH)/gpc \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/include/utils
AGG_SRCS := \
$(LOCAL_PATH)/font_freetype/agg_font_freetype.cpp \
$(LOCAL_PATH)/gpc/gpc.cpp \
$(LOCAL_PATH)/src/*.cpp \
LOCAL_CPP_EXTENSION := .cpp
include $(BUILD_STATIC_LIBRARY)
I have found it best to build each lib independently (i.e. freetype and agg). Then build seGraphics by linking against both freetype and agg using the following: LD_FLAGS += -lfreetype -lagg.