I have a problem when creating an executable with ndk using the BOOST libraries in c ++ using already mentioned ndk, this is the problem
C:\Users\GENERAL\Downloads\Compressed\tcpproxy\proxy\jni>ndk-build
[armeabi] Compile++ thumb: proxy <= tcpproxy_server.cpp
[armeabi] Executable : proxy
C:/Users/GENERAL/Downloads/Compressed/tcpproxy/proxy//jni/boost_1_56_0/boost/sys
tem/error_code.hpp:322: error: undefined reference to 'boost::system::system_cat
egory()'
C:/Users/GENERAL/Downloads/Compressed/tcpproxy/proxy//jni/boost_1_56_0/boost/thr
ead/exceptions.hpp:51: error: undefined reference to 'boost::system::system_cate
gory()'
C:/Users/GENERAL/Downloads/Compressed/tcpproxy/proxy//jni/boost_1_56_0/boost/asi
o/error.hpp:225: error: undefined reference to 'boost::system::system_category()
'
C:/Users/GENERAL/Downloads/Compressed/tcpproxy/proxy//jni/boost_1_56_0/boost/asi
o/error.hpp:225: error: undefined reference to 'boost::system::system_category()
'
C:/Users/GENERAL/Downloads/Compressed/tcpproxy/proxy//jni/boost_1_56_0/boost/sys
tem/error_code.hpp:221: error: undefined reference to 'boost::system::generic_ca
tegory()'
C:/Users/GENERAL/Downloads/Compressed/tcpproxy/proxy//jni/boost_1_56_0/boost/sys
tem/error_code.hpp:222: error: undefined reference to 'boost::system::generic_ca
tegory()'
collect2.exe: error: ld returned 1 exit status
make.exe: *** [C:/Users/GENERAL/Downloads/Compressed/tcpproxy/proxy//obj/local/a
rmeabi/proxy] Error 1
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/boost_1_56_0 #patch of include BOOST
LOCAL_MODULE := proxy
LOCAL_SRC_FILES := tcpproxy_server.cpp
include $(BUILD_EXECUTABLE)
Application.mk
APP_CFLAGS += -fexceptions
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION := 4.8
APP_CPPFLAGS := -std=c++11
that is the error that I get when compiling. already investigate but can not find the solution so please thank your answer to be able to repair it and because generating that error thanks
You may need to add the boost_system library. You can add -lboost_system to your linker flags to find related library symbols in Android.mk (Assuming that boost is built as static):
LOCAL_STATIC_LIBRARIES = -lboost_system ...
include $(BUILD_STATIC_LIBRARY)
Related
I am struggling with this problem since few weeks I hope someone can help me.
I have created a C function wrapper in my Android app that impements the JNI export. I have also created a second .so library in order to call my original library but here I have a problem when linking with ndk-build. This is my code:
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := my_prebuilt_lib
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../jni/
LOCAL_SRC_FILES := ../jniLibs/$(TARGET_ARCH_ABI)/my_prebuilt_lib.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := myjni
LOCAL_SRC_FILES := wrapper.cpp
LOCAL_SHARED_LIBRARY += my_prebuilt_lib
include $(BUILD_SHARED_LIBRARY)
This is the command I am using to build myjni.so:
ndk-build NDK_PROJECT_PATH=./ NDK_APPLICATION_MK=./jni/Application.mk
And I get this error:
Android NDK: WARNING: APP_PLATFORM android-16 is higher than android:minSdkVersion 1 in .//AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android-16. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.
[armeabi-v7a] Install : my_prebuilt_lib.so => libs/armeabi-v7a/liblocSDK4d.so
[armeabi-v7a] Compile++ thumb: myjni <= wrapper.cpp
[armeabi-v7a] SharedLibrary : libmyjni.so
jni/wrapper.cpp:24: error: undefined reference to 'hex2int(char)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Looking into my_prebuilt_lib.so I can see the following declaration about the function I want to call:
00004c51 T hex2int(char)
Any suggestion?
This is the error I get when using Boost library for Android. I am using Android NDK r8e and boost 1.53 and followed this tutorial.
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lgnustl_static
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: jni/boost/lib//libboost_regex-gcc-mt-1_53.a(instances.o): in function boost::object_cache<boost::re_detail::cpp_regex_traits_base<char>, boost::re_detail::cpp_regex_traits_implementation<char> >::do_get(boost::re_detail::cpp_regex_traits_base<char> const&, unsigned int):/home/tassilo/android-ndks/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_list.h:1508: error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: jni/boost/lib//libboost_regex-gcc-mt-1_53.a(instances.o): in function boost::object_cache<boost::re_detail::cpp_regex_traits_base<char>, boost::re_detail::cpp_regex_traits_implementation<char> >::do_get(boost::re_detail::cpp_regex_traits_base<char> const&, unsigned int):/home/tassilo/android-ndks/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_list.h:1508: error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: jni/boost/lib//libboost_regex-gcc-mt-1_53.a(instances.o): in function boost::object_cache<boost::re_detail::cpp_regex_traits_base<char>, boost::re_detail::cpp_regex_traits_implementation<char> >::do_get(boost::re_detail::cpp_regex_traits_base<char> const&, unsigned int):/home/tassilo/android-ndks/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_list.h:1516: error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: jni/boost/lib//libboost_regex-gcc-mt-1_53.a(instances.o): in function boost::object_cache<boost::re_detail::cpp_regex_traits_base<char>, boost::re_detail::cpp_regex_traits_implementation<char> >::do_get(boost::re_detail::cpp_regex_traits_base<char> const&, unsigned int):/home/tassilo/android-ndks/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_list.h:1532: error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libusit.so] Error 1
This is how my make file looks like:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include ./jni/opencv/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := usit
LOCAL_SRC_FILES := cr.cpp
LOCAL_CFLAGS += -I$(LOCAL_PATH)/boost/include/boost-1_53
LOCAL_LDLIBS += -L$(LOCAL_PATH)/boost/lib/ -lboost_system-gcc-mt-1_53 -lboost_regex-gcc-mt-1_53 -lboost_filesystem-gcc-mt-1_53 -lboost_date_time-gcc-mt-1_53 \
-L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/armeabi \
-lgnustl_static
include $(BUILD_SHARED_LIBRARY)
As suggested in the tutorial I am specifying the path to NDK Root. I am using Ubuntu 12.04 and defined the NDK_ROOT variable in .bashrc and .profile like this:
export NDK_ROOT=${HOME}/android-ndks/android-ndk-r8e
I appreciate any help.
EDIT:
This is my Application.mk
APP_PLATFORM := android-8
APP_ABI := armeabi-v7a
APP_OPTIM := debug
NDK_DEBUG := 1
NDK_TOOLCHAIN_VERSION := 4.6
APP_STL := gnustl_static
APP_CPPFLAGS := -fexceptions -frtti
To use gnustl (static or shared), you need parameter APP_STL. Usually, we set it in Application.mk, but you can also set it on command line (do this with care, never mix different values).
I recommend to install the latest NDK, and not use the outdated 4.6 toolchain.
Example of Application.mk:
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION := 4.8
APP_CPPFLAGS := -std=c++11
I am new in NDK and i want to use a c library in my application. I try with a simple c file and it work. I succeded to send and receive data between the two api. But when i want to introduce an existing c library i have this kind of error when i run ndk-build.
root#xxx:~/workspace/Myproject# ndk-build
Android NDK: WARNING: APP_PLATFORM android-16 is larger than android:minSdkVersion 8 in /root/workspace/MyOpus/AndroidManifest.xml
[armeabi-v7a] Compile thumb : my_manager <= myencoder.c
[armeabi-v7a] SharedLibrary : libmy_manager.so
/usr/local/mes_installations/android_tool/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: ./obj/local/armeabi-v7a/libopus.so: incompatible target
/usr/local/mes_installations/android_tool/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/objs/my_manager/src/myencoder.o: in function myEncodeOpus:/root/workspace/MyOpus/jni/src/myencoder.c:81: error: undefined reference to 'opus_encoder_create'
/usr/local/mes_installations/android_tool/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/objs/my_manager/src/myencoder.o: in function myEncodeOpus:/root/workspace/MyOpus/jni/src/myencoder.c:84: error: undefined reference to 'opus_strerror'
/usr/local/mes_installations/android_tool/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/objs/my_manager/src/myencoder.o: in function myEncodeOpus:/root/workspace/MyOpus/jni/src/myencoder.c:93: error: undefined reference to 'opus_encoder_ctl'
/usr/local/mes_installations/android_tool/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/objs/my_manager/src/myencoder.o: in function myEncodeOpus:/root/workspace/MyOpus/jni/src/myencoder.c:96: error: undefined reference to 'opus_strerror'
/usr/local/mes_installations/android_tool/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/objs/my_manager/src/myencoder.o: in function myEncodeOpus:/root/workspace/MyOpus/jni/src/myencoder.c:120: error: undefined reference to 'opus_encode'
/usr/local/mes_installations/android_tool/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/objs/my_manager/src/myencoder.o: in function myEncodeOpus:/root/workspace/MyOpus/jni/src/myencoder.c:123: error: undefined reference to 'opus_strerror'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libmy_manager.so] Error 1
How can i solve this problem? I read all the Android.mk documentation but i did not see any thing to solve it. Regards
you said you succeed to create shared library libmy_manager . in Android.mk specify the path of libmy_manager.so and the path of header files
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libmy_manager
LOCAL_SRC_FILES := libmy_manager.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include #path of header file with define
# function in libmy_manager
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := my_manager
LOCAL_SRC_FILES := my_manager.c
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SHARED_LIBRARIES := libmy_manager
include $(BUILD_SHARED_LIBRARY)
Hi
I had try to compile the following Android.mk file using ndk-build.
I got the following errors. how can I resolve this problem?
please help me.
the make file is
# ================================================== ========
# NOTE:
# when executing binary, set LD_LIBRARY_PATH in device
# ================================================== ========
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
BASEDIR := ../../..
DISTDIR := ../../../..
LOCAL_MODULE := EvaluateFingerQuality
LOCAL_ARM_MODE := arm
# Includes
LOCAL_C_INCLUDES += \
$(BASEDIR)/Common/C \
$(DISTDIR)/Include
# Source files
LOCAL_SRC_FILES := \
$(BASEDIR)/Common/C/Utils.c \
EvaluateFingerQuality.c
LOCAL_LDLIBS += \
-Wl,-z,muldefs -Wl,-rpath=$(DISTDIR)/Lib/Android_$(TARGET_ARCH_ABI) \
-L $(DISTDIR)/Lib/Android_$(TARGET_ARCH_ABI) \
-lNLicensing -lNBiometricTools -lNBiometrics -lNMedia -lNCore -lc
include $(BUILD_EXECUTABLE)
the error is
$ ndk-build
Compile arm : EvaluateFingerQuality <= Utils.c
Compile arm : EvaluateFingerQuality <= EvaluateFingerQuality.c
Executable : EvaluateFingerQuality
../../../../Lib/Android_armeabi/libNCore.so: undefined reference to `pthread_rwlock_trywrlock'
../../../../Lib/Android_armeabi/libNCore.so: undefined reference to `pthread_rwlock_rdlock'
../../../../Lib/Android_armeabi/libNCore.so: undefined reference to `pthread_rwlock_tryrdlock'
../../../../Lib/Android_armeabi/libNCore.so: undefined reference to `pthread_rwlock_wrlock'
../../../../Lib/Android_armeabi/libNCore.so: undefined reference to `dladdr'
../../../../Lib/Android_armeabi/libNCore.so: undefined reference to `pthread_rwlock_destroy'
../../../../Lib/Android_armeabi/libNCore.so: undefined reference to `pthread_rwlock_init'
../../../../Lib/Android_armeabi/libNCore.so: undefined reference to `pthread_rwlock_unlock'
collect2: ld returned 1 exit status
/cygdrive/d/android-ndk-r8-windows/android-ndk-r8/build/core/build-binary.mk:381: recipe for target `/cygdrive/d/MegaMatcher_Embedded_1_2_SDK_Trial_for_Android/Tutorials/BiometricTools/C/obj/local/armeabi/EvaluateFingerQuality' failed
make: *** [/cygdrive/d/MegaMatcher_Embedded_1_2_SDK_Trial_for_Android/Tutorials/BiometricTools/C/obj/local/armeabi/EvaluateFingerQuality] Error 1
Android supports pthreads strating from API 9 version. i got the above error due to i am using old version of NDK. to avoid this build like this "$ndk-build APP_PLATFORM=android-9 "
I'm tryng to port an iOS game to Android platform with cocos2dx 2.0.4.
The core of the game is written in c++ and we managed to run it on iOS, in fact the game is avaivable on the Apple Store.
I'm using NDK r8d and lastest SDK, but I'm encountering a lot of issues when trying to build.
My application.mk is like this:
APP_STL := stlport_shared
APP_CPPFLAGS := -frtti
NDK_TOOLCHAIN_VERSION=4.7
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifdef STLG
LOCAL_MODULE := stlport_stlg
else
LOCAL_MODULE := stlport
endif
LOCAL_CFLAGS += -D__ANDROID__ \
-isystem $(SYSROOT)/usr/include \
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
LOCAL_CPPFLAGS += -fexceptions
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes $(LOCAL_PATH)/../../../../Box2D $(LOCAL_PATH)/../../../../cocos2dx $(LOCAL_PATH)/../../../../
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions)
Here's the console log (only errors displayed):
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_alloc.h:158: error: undefined reference to 'std::__node_alloc::_M_allocate(unsigned int&)'
make: Leaving directory `/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_alloc.h:161: error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_string.c:600: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android/../../cocos2dx/actions/CCActionInterval.cpp:386: error: undefined reference to '__dynamic_cast'
/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android/../../cocos2dx/actions/CCActionInterval.cpp:1783: error: undefined reference to '__dynamic_cast'
/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android/../../cocos2dx/actions/CCActionInterval.cpp:1838: error: undefined reference to '__dynamic_cast'
/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android/../../cocos2dx/actions/CCActionInterval.cpp:1906: error: undefined reference to '__dynamic_cast'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_vector.c:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_vector.c:45: error: undefined reference to 'std::__stl_throw_out_of_range(char const*)'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_string.c:604: error: undefined reference to 'std::__stl_throw_out_of_range(char const*)'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_vector.c:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
./obj/local/armeabi/libcocos2d.a(CCDirector.o):CCDirector.cpp:function typeinfo for cocos2d::CCDirector: error: undefined reference to 'vtable for __cxxabiv1::__vmi_class_type_info'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_vector.c:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libgame.so] Error 1
Any help much appreciated, thanks...
Try this in application.mk APP_STL := gnustl_static?
You get the above undefined reference error because you have not added the necessary libraries in Android.mk files. It looks something like this
LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/$(TARGET_ARCH_ABI)) \
-lcocos2d -lGLESv1_CM -llog -lgame_logic
I am stuck with this issue even after adding the libraries. Its got something to do with setting path but I dont know how to..
If you solve this let me know