I need to add to android project atom processor support. Config and build libvpx library under x86 with parameters:
./configure --disable-examples --sdk-path = '/ Android / ndk' --enable-vp8 --target = x86-android-gcc --disable-postproc
make
build success and I get a static library libvpx.a
Add library to project:
include $ (CLEAR_VARS)
LOCAL_MODULE: = vpx
LOCAL_SRC_FILES: = thirdparty / webm / libvpx / $ (TARGET_ARCH_ABI) / libvpx.a
include $ (PREBUILT_STATIC_LIBRARY)
LOCAL_STATIC_LIBRARIES: = stdc++ jpeg png vorbis vorbisfile vorbisenc theora theoradec libwebp vpx
but during the assembly of the project was getting errors :
jni/thirdparty/webm/libvpx/x86/libvpx.a (vp8_dx_iface.co) (. text +0 x568): error: undefined reference to '__vsnprintf_chk'
jni/thirdparty/webm/libvpx/x86/libvpx.a (vp8_dx_iface.co) (. text +0 x596): error: undefined reference to '__longjmp_chk'
jni/thirdparty/webm/libvpx/x86/libvpx.a (onyxd_if.co) (. text +0 x158): error: undefined reference to '__vsnprintf_chk'
jni/thirdparty/webm/libvpx/x86/libvpx.a (onyxd_if.co) (. text +0 x186): error: undefined reference to '__longjmp_chk'
jni/thirdparty/webm/libvpx/x86/libvpx.a (onyxd_if.co) (. text.unlikely +0 x23): error: undefined reference to '__assert_fail'
jni/thirdparty/webm/libvpx/x86/libvpx.a (yv12extend.co): function vp8_yv12_extend_frame_borders_c: error: undefined reference to '__assert_fail'
jni/thirdparty/webm/libvpx/x86/libvpx.a (yv12extend.co): function vp8_yv12_extend_frame_borders_c: error: undefined reference to '__assert_fail'
jni/thirdparty/webm/libvpx/x86/libvpx.a (yv12extend.co): function vp8_yv12_extend_frame_borders_c: error: undefined reference to '__assert_fail'
jni/thirdparty/webm/libvpx/x86/libvpx.a (decodframe.co) (. text +0 x198): error: undefined reference to '__vsnprintf_chk'
jni/thirdparty/webm/libvpx/x86/libvpx.a (decodframe.co) (. text +0 x1c6): error: undefined reference to '__longjmp_chk'
jni/thirdparty/webm/libvpx/x86/libvpx.a (boolhuff.co) (. text +0 x55): error: undefined reference to '__longjmp_chk'
jni/thirdparty/webm/libvpx/x86/libvpx.a (onyx_if.co) (. text +0 xa08): error: undefined reference to '__vsnprintf_chk'
Does anyone know how to fix it? Build project under armeabi is successfully.
Trying to add flags APP_CPPFLAGS +=-std=gnu++11 and change the version of ndk
NDK_TOOLCHAIN_VERSION: = 4.8
other flags of the project:
APP_STL: = gnustl_static
APP_CPPFLAGS + =-frtti-fexceptions
APP_CFLAGS + =-Wno-error = format-security
APP_ABI: = armeabi x86
used in the construction of ndk android-ndk-r9d-linux-x86 (I tried to use android-ndk-r9d-linux-x86_64 - the same result), Ubuntu 13.10 x86_64, Eclipse 3.8.1
For me adding --extra-cflags="-U_FORTIFY_SOURCE" covered __longjmk_chk and __vsnprintf_chk
And I wrote empty __assert_fail function : extern "C" { void __assert_fail() {} }
Related
I am trying to compile openssl for android and facing some issues. I am following the steps given in this link.
I am using NDK version r20 and OpenSSL 1.1.1c and on a linux machine.
I am facing two issues:
(1) I am able to compile libs for “android-arm” architecture but getting the below errors while compiling sample application.
./libcrypto.so: error: undefined reference to ‘sigdelset’
./libcrypto.so: error: undefined reference to ‘sigfillset’
./libcrypto.so: error: undefined reference to ‘tcgetattr’
./libcrypto.so: error: undefined reference to ‘tcsetattr’
apps/ocsp.o:ocsp.c:function ocsp_main: error: undefined reference to ‘signal’
apps/ocsp.o:ocsp.c:function ocsp_main: error: undefined reference to ‘signal’
apps/ocsp.o:ocsp.c:function ocsp_main: error: undefined reference to ‘signal’
apps/ocsp.o:ocsp.c:function ocsp_main: error: undefined reference to ‘signal’
apps/ocsp.o:ocsp.c:function process_responder: error: undefined reference to ‘__FD_SET_chk’
apps/ocsp.o:ocsp.c:function process_responder: error: undefined reference to ‘__FD_SET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_SET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_SET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_ISSET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_ISSET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_ISSET_chk’
apps/s_client.o:s_client.c:function s_client_main: error: undefined reference to ‘__FD_ISSET_chk’
apps/speed.o:speed.c:function speed_main: error: undefined reference to ‘atof’
apps/speed.o:speed.c:function speed_main: error: undefined reference to ‘atof’
apps/speed.o:speed.c:function speed_main: error: undefined reference to ‘atof’
apps/speed.o:speed.c:function speed_main: error: undefined reference to ‘atof’
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(2) I am not able to compile for any other architecture. If I change architecture to “android-arm64” (or any other), I am getting the below errors while compiling library.
crypto/aes/aesv8-armx.S:5:1: error: Unknown arch name
.arch armv8-a+crypto
^
crypto/aes/aesv8-armx.S:17:2: error: invalid instruction, did you mean: stc, stm, str, swp, tst?
stp x29,x30,[sp,#-16]!
^
crypto/aes/aesv8-armx.S:18:6: error: operand must be a register in range [r0, r15]
add x29,sp,#0
^
crypto/aes/aesv8-armx.S:19:6: error: operand must be a register in range [r0, r12] or r14
mov x3,#-1
^
I am changing the architecture by changing the “architecture=android-arm” in the “file-launcher-sh”. Do I need to modify any other variables/macros?
You built openssl for a newer API level than your app, so the library is not compatible with your app. Here's how I build openssl with r20:
$ export ANDROID_NDK=/path/to/ndk
$ export PATH=$ANDROID_NDK/toolchains/llvm/prebuilt/$HOST/bin:$PATH
$ path/to/openssl/Configure android-$ARCH -D__ANDROID_API__=$MINSDKVERSION --prefix=$INSTALLPATH --openssldir=$INSTALLPATH shared
$ make SHLIB_EXT=.so install_sw
I just had to open new putty for each new architecture.
I think somehow few of the configurations/variables exported for one architecture are not getting updated when I re-run the script with new architecture.
Add the compiler flag "no-asm" to ./Configure
./Configure no-asm no-shared android-$ARCH -D__ANDROID_API__=$MINSDKVERSION --prefix=$INSTALLPATH --openssldir=$INSTALLPATH shared
I had following error when done cross compilation for android.
Cross compiler used SDK/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi'
./libgpsd.a(libgpsd_core.o):libgpsd_core.c:function gpsd_poll: error: undefined reference to '__isfinite'
./libgpsd.a(libgpsd_core.o):libgpsd_core.c:function gpsd_poll: error: undefined reference to '__isfinite'
./libgpsd.a(libgpsd_core.o):libgpsd_core.c:function gpsd_poll: error: undefined reference to '__isfinite'
./libgpsd.a(libgpsd_core.o):libgpsd_core.c:function gpsd_poll: error: undefined reference to '__isfinite'
The function infinite() is part of C99. Add LOCAL_CFLAGS += -std=c99 to your Android.mk. See question How to set standard c99 for compile android NDK project
I have generated Uclib using buildroot and used it to compile mpich for ARM devices.Then I created Android project and copied libmpich.a and the Include folder to the project here is the Android.mk:
LOCAL_PATH := $(call my-dir)
# static library info
LOCAL_MODULE_FILENAME:= libmpich
LOCAL_MODULE := libmpich
LOCAL_SRC_FILES := ../prebuilt/libmpich.a
LOCAL_EXPORT_C_INCLUDES := ../prebuilt/include
LOCAL_STATIC_LIBRARIES := libmpich
include $(PREBUILT_STATIC_LIBRARY)
# wrapper info
include $(CLEAR_VARS)
LOCAL_C_INCLUDES += ../prebuilt/include
LOCAL_MODULE := ndk1
LOCAL_SRC_FILES := native.c
LOCAL_STATIC_LIBRARIES := libmpich
include $(BUILD_SHARED_LIBRARY)
after ndk-build i got the following error
jni/../prebuilt/libmpich.a(initthread.o):initthread.c:function PMPI_Init_thread: error: undefined reference to 'MPL_env2bool'
jni/../prebuilt/libmpich.a(msgprint.o):msgprint.c:function MPIU_Usage_printf: error: undefined reference to 'stdout'
jni/../prebuilt/libmpich.a(msgprint.o):msgprint.c:function MPIU_Error_printf: error: undefined reference to 'stderr'
jni/../prebuilt/libmpich.a(msgprint.o):msgprint.c:function MPIU_Internal_error_printf: error: undefined reference to 'stderr'
jni/../prebuilt/libmpich.a(msgprint.o):msgprint.c:function MPIU_Internal_sys_error_printf: error: undefined reference to 'stderr'
jni/../prebuilt/libmpich.a(msgprint.o):msgprint.c:function MPIU_Msg_printf: error: undefined reference to 'stdout'
jni/../prebuilt/libmpich.a(dbg_printf.o):dbg_printf.c:function MPIU_dbg_printf: error: undefined reference to 'stdout'
jni/../prebuilt/libmpich.a(dbg_printf.o):dbg_printf.c:function MPIU_dump_dbg_memlog_to_stdout: error: undefined reference to 'stdout'
jni/../prebuilt/libmpich.a(param_vals.o):param_vals.c:function MPIR_Param_init_params: error: undefined reference to 'MPL_env2int'
jni/../prebuilt/libmpich.a(param_vals.o):param_vals.c:function MPIR_Param_init_params: error: undefined reference to 'MPL_env2int'
jni/../prebuilt/libmpich.a(param_vals.o):param_vals.c:function MPIR_Param_init_params: error: undefined reference to 'MPL_env2int'
jni/../prebuilt/libmpich.a(param_vals.o):param_vals.c:function MPIR_Param_init_params: error: undefined reference to 'MPL_env2int'
jni/../prebuilt/libmpich.a(param_vals.o):param_vals.c:function MPIR_Param_init_params: error: undefined reference to 'MPL_env2bool'
jni/../prebuilt/libmpich.a(param_vals.o):param_vals.c:function MPIR_Param_init_params: error: undefined reference to 'MPL_env2bool'
jni/../prebuilt/libmpich.a(param_vals.o):param_vals.c:function MPIR_Param_init_params: error: undefined reference to 'MPL_env2bool'
jni/../prebuilt/libmpich.a(param_vals.o):param_vals.c:function MPIR_Param_init_params: error: undefined reference to 'MPL_env2str'
jni/../prebuilt/libmpich.a(param_vals.o):param_vals.c:function MPIR_Param_init_params: error: undefined reference to 'MPL_env2str'
jni/../prebuilt/libmpich.a(mpid_abort.o):mpid_abort.c:function MPID_Abort: error: undefined reference to 'stderr'
jni/../prebuilt/libmpich.a(mpid_vc.o):mpid_vc.c:function MPIDI_Populate_vc_node_ids: error: undefined reference to '__errno_location'
jni/../prebuilt/libmpich.a(mpid_vc.o):mpid_vc.c:function MPIDI_Populate_vc_node_ids: error: undefined reference to '__ctype_b'
jni/../prebuilt/libmpich.a(init.o):init.c:function PMPI_Init: error: undefined reference to 'MPL_env2str'
jni/../prebuilt/libmpich.a(strerror.o):strerror.c:function MPIU_Strerror: error: undefined reference to '__xpg_strerror_r'
jni/../prebuilt/libmpich.a(simple_pmi.o):simple_pmi.c:function accept_one_connection: error: undefined reference to '__errno_location'
jni/../prebuilt/libmpich.a(simple_pmi.o):simple_pmi.c:function PMI_Init: error: undefined reference to '__errno_location'
jni/../prebuilt/libmpich.a(sock.o):sock.c:function MPIDU_Socki_event_enqueue.isra.1: error: undefined reference to '__errno_location'
jni/../prebuilt/libmpich.a(sock.o):sock.c:function MPIDU_Sock_listen: error: undefined reference to 'MPL_env2range'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libndk1.so] Error 1
I don't understand why it is not linking correctly and what is missing
Update :
when I add libmpl.a to the project all MPL errors disappeared
I think your problem occured because your static lib libmpich.a has dependance on another lib.
You have two diffenrent way to solve this issue :
Import any library needed by your libmpich.a as static library in your Android.mk as static library. The problem of this approach is that can be very long and painful if you have a lot dependance.
Build libmpich as a dynamic library, as dynamic library are package with their dependance. I do know how you build you libmpich library so i don't know if this will be hard to achieve. Once you have libmpich.so import it in your Android.mk as a dynamic library instead of a static one.
There have been some questions similar to mine, but it seems that their solutions don't work for me.
I'm trying to compile dumpsys source code using Android NDK. I have added a couple of lines to Android.mk to include the libraries.
The final Android.mk file looks like this:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
dumpsys.cpp
LOCAL_SHARED_LIBRARIES := \
libutils \
liblog \
libbinders
ANDROID_SRC="my android source directory"
LOCAL_C_INCLUDES := ${ANDROID_SRC}/frameworks/native/include \
${ANDROID_SRC}/system/core/include
#$(warning $(TARGET_C_INCLUDES))
LOCAL_MODULE:= dumpsys
TARGET_ARCH := arm
TARGET_ARCH_ABI := armeabi-v7a
include $(BUILD_EXECUTABLE)
when I execute ndk-build, I get the following errors:
/home/mahdi/university/androidsource/system/core/include/utils/TypeHelpers.h:144: error: undefined reference to 'android::String16::~String16()'
/home/mahdi/university/androidsource/system/core/include/utils/Vector.h:240: error: undefined reference to 'android::VectorImpl::finish_vector()'
/home/mahdi/university/androidsource/system/core/include/utils/Vector.h:241: error: undefined reference to 'android::VectorImpl::~VectorImpl()'
/home/mahdi/university/androidsource/system/core/include/utils/TypeHelpers.h:135: error: undefined reference to 'android::String16::String16()'
/home/mahdi/university/androidsource/system/core/include/utils/TypeHelpers.h:154: error: undefined reference to 'android::String16::String16(android::String16 const&)'
/home/mahdi/university/androidsource/system/core/include/utils/TypeHelpers.h:166: error: undefined reference to 'android::String16::String16(android::String16 const&)'
/home/mahdi/university/androidsource/system/core/include/utils/String16.h:178: error: undefined reference to 'strzcmp16'
/home/mahdi/university/androidsource/system/core/include/utils/StrongPointer.h:143: error: undefined reference to 'android::RefBase::decStrong(void const*) const'
jni/dumpsys.cpp:32: error: undefined reference to 'android::defaultServiceManager()'
jni/dumpsys.cpp:35: error: undefined reference to '__android_log_print'
/home/mahdi/university/androidsource/system/core/include/utils/Vector.h:224: error: undefined reference to 'android::VectorImpl::VectorImpl(unsigned int, unsigned int)'
/home/mahdi/university/androidsource/system/core/include/utils/Vector.h:224: error: undefined reference to 'android::VectorImpl::VectorImpl(unsigned int, unsigned int)'
/home/mahdi/university/androidsource/system/core/include/utils/Vector.h:245: error: undefined reference to 'android::VectorImpl::operator=(android::VectorImpl const&)'
/home/mahdi/university/androidsource/system/core/include/utils/Vector.h:378: error: undefined reference to 'android::VectorImpl::sort(int (*)(void const*, void const*))'
jni/dumpsys.cpp:49: error: undefined reference to 'android::String16::String16(char const*)'
/home/mahdi/university/androidsource/system/core/include/utils/Vector.h:338: error: undefined reference to 'android::VectorImpl::add(void const*)'
jni/dumpsys.cpp:49: error: undefined reference to 'android::String16::~String16()'
jni/dumpsys.cpp:51: error: undefined reference to 'android::String16::String16(char const*)'
/home/mahdi/university/androidsource/system/core/include/utils/Vector.h:338: error: undefined reference to 'android::VectorImpl::add(void const*)'
jni/dumpsys.cpp:51: error: undefined reference to 'android::String16::~String16()'
jni/dumpsys.cpp:53: error: undefined reference to 'android::String16::String16(char const*)'
/home/mahdi/university/androidsource/system/core/include/utils/Vector.h:338: error: undefined reference to 'android::VectorImpl::add(void const*)'
jni/dumpsys.cpp:53: error: undefined reference to 'android::String16::~String16()'
jni/dumpsys.cpp:66: error: undefined reference to 'android::operator<<(android::TextOutput&, android::String16 const&)'
jni/dumpsys.cpp:81: error: undefined reference to 'android::operator<<(android::TextOutput&, android::String16 const&)'
jni/dumpsys.cpp:89: error: undefined reference to 'android::operator<<(android::TextOutput&, android::String16 const&)'
/home/mahdi/university/androidsource/system/core/include/utils/StrongPointer.h:143: error: undefined reference to 'android::RefBase::decStrong(void const*) const'
jni/dumpsys.cpp:94: error: undefined reference to 'android::aerr'
jni/dumpsys.cpp:94: error: undefined reference to 'android::aout'
collect2: error: ld returned 1 exit status
How should I solve this issue?
Thanks in advance.
I'm working on a similar issue here.
Basically, dumpsys is an AOSP component and intended to be built with the AOSP toolchain. You will need to apply some tweaks to port it to NDK – including stuff from ${ANDROID_SRC} is the first step but not the whole story.
You've successfully included the headers and thus made the compiler happy. Now the linker is complaining because it cannot find the libraries you are linking against. The good news is that they are shared libraries, thus having the libraries around at build time isn't a strict requirement.
The NDK defines a stable API of libraries you can use, which is documented here. liblog is in that list and can be included by adding the following lines to Android.mk:
LOCAL_LDLIBS := \
-llog \
The other two libraries are not part of the stable API. This essentially means that even if your code works on a particular version of Android, it may break on any later version because the API may have changed – you might want to bear this in mind.
Since these libraries are shared, all ld does is check if they actually provide the functions you're using. This question and its accepted answer have instructions for getting rid of the related error messages:
One way is to use something like:
LOCAL_LDFLAGS := -Wl,--unresolved-symbols=ignore-all
However, this will bypass all checks – so if you try to use a function that is indeed absent from the library, ld has no chance of warning you.
The cleaner, but more work-intensive approach, is to provide stub libraries. A stub library is essentially a dummy library which defines the same symbols (functions etc.) as the "real" thing but has no implementation (functions simply return without doing anything). It's enough to make the linker happy, but the libraries are not shipped and their "real" counterparts are used at runtime.
You would need to get the source code for the two libraries, which reside in the following directories: libutils and libbinders
system/core/libutils
frameworks/native/libs/binder
Copy these two dirs into your project's jni dir. Then strip the code down:
* Edit Android.mk, removing all build targets other than BUILD_SHARED_LIBRARY.
* Edit the source code files, replacing all function bodies with a simple return. It doesn't matter what you return, as long as you get the code to compile.
Eventually you will probably need to prevent the stub libraries from getting included in your .apk (I have yet to figure out how to do that).
I'm new to Qt and now I'm using Qt creator to develop android application in Win7 OS.
The problem is when I try to call function in the .a library provided by an external company, there are undefined reference errors.
I've already told him my ndk revision and android cpu architecture, and then he re-compiled and gave me this .a file.
My Qt version is Qt 5.3.2 for Android, and the ndk is r10d.
The error message:
D:/android/tools/android-ndk-r10/sources/cxx-stl/stlport/stlport/stl/_alloc.h:158: error: undefined reference to 'std::__node_alloc::_M_allocate(unsigned int&)'
D:/android/tools/android-ndk-r10/sources/cxx-stl/stlport/stlport/stl/_alloc.h:161: error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
Makefile:79: recipe for target 'libuntitled.so' failed
D:/android/tools/android-ndk-r10/sources/cxx-stl/stlport/stlport/stl/_vector.h:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
D:/android/tools/android-ndk-r10/sources/cxx-stl/stlport/stlport/stl/_vector.h:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
D:/android/tools/android-ndk-r10/sources/cxx-stl/stlport/stlport/stl/_vector.h:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
D:/android/tools/android-ndk-r10/sources/cxx-stl/stlport/stlport/stl/_vector.h:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
collect2.exe: eooro: ld returned 1 exit status
The strange thing is that my ndk wasn't even installed in this directory!
Can any figure out why the errors occured?