Compiling OpenSSL for android ndk r17b - android

I tried How to build and integrate OpenSSL into your Android NDK project – Scottyab's blog, but had problems with it:
Error message
openssl/x86_64/lib/libcrypto.a(eng_openssl.o):eng_openssl.c:function test_rc4_init_key: error: undefined reference to 'stderr'
openssl/x86_64/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function close_console: error: undefined reference to 'stdin'
openssl/x86_64/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function close_console: error: undefined reference to 'stderr'
openssl/x86_64/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stdin'
openssl/x86_64/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stderr'
I tried Compilation fails with android ndk r15b · Issue #3826 · openssl/openssl's comment, and it did remove one of the errors, but the others were left.
Compilation fails with android ndk r15b · Issue #3826 · openssl/openssl's comment has suggests using --deprecated-headers, didn't work either.
NDK: Unified Headers issue · Issue #445 · android-ndk/ndk's comment says it's resolved. I tried setting the CFLAGS=-D__ANDROID_API__=$API but it didn't help.
I also tried using clang as the compiler using and got
clang: error: unknown argument: '-mandroid'
Android Studio: clang error: unknown argument: '-mandroid''s answer has a good explanation for it.
Actually faisal00813/openssl_for_ios_and_android: OpenSSL Library for iOS and Android fork uses clang as the compiler and the -mandroid bug is resolved, but still getting the undefined reference to 'stdin'

I finally used willyliu/build-openssl-android: Builds openssl 1.1.0h with android ndk r17., and it worked great. My fork david-hoze/build-openssl-android: Builds openssl 1.1.0h with android ndk r17. has some minor fixes

Related

NCurses 6.0 Compilation Error Using Android-NDK

I'm trying to cross-compile ncurses using android-ndk but compilation error shows halfway the process.
Command:
CC=~/my-toolchain/bin/arm-linux-androideabi-gcc ./configure --host=arm-linux-androideabi --prefix=/Android
Output:
** Configuration summary for NCURSES 6.0 20150808:
extended funcs: yes
xterm terminfo: xterm-new
bin directory: /Android/bin
lib directory: /Android/lib
include directory: /Android/include/ncurses
man directory: /Android/share/man
terminfo directory: /Android/share/terminfo
** Include-directory is not in a standard location
Command
make
Output
../objects/tic.o:tic.c:function usage: error: undefined reference to 'stderr'
../objects/tic.o:tic.c:function put_translate: error: undefined reference to 'stdout'
../objects/tic.o:tic.c:function copy_input: error: undefined reference to 'stderr'
../objects/tic.o:tic.c:function open_input: error: undefined reference to 'stdin'
../objects/tic.o:tic.c:function open_input: error: undefined reference to 'stderr'
../objects/tic.o:tic.c:function show_databases: error: undefined reference to 'stdout'
../objects/tic.o:tic.c:function show_databases: error: undefined reference to 'stderr'
../objects/dump_entry.o:dump_entry.c:function show_entry: error: undefined reference to 'stdout'
../objects/dump_entry.o:dump_entry.c:function compare_entry: error: undefined reference to 'stdout'
../lib/libncurses.a(lib_twait.o):lib_twait.c:function _nc_timed_wait: error: undefined reference to '__FD_SET_chk'
../lib/libncurses.a(lib_twait.o):lib_twait.c:function _nc_timed_wait: error: undefined reference to '__FD_SET_chk'
../lib/libncurses.a(lib_twait.o):lib_twait.c:function _nc_timed_wait: error: undefined reference to '__FD_ISSET_chk'
../lib/libncurses.a(lib_twait.o):lib_twait.c:function _nc_timed_wait: error: undefined reference to '__FD_ISSET_chk'
collect2: error: ld returned 1 exit status
Makefile:242: recipe for target 'tic' failed
make[1]: *** [tic] Error 1
make[1]: Leaving directory '/home/jrm/softether/src/curses/ncurses-6.0/progs'
Makefile:113: recipe for target 'all' failed
make: *** [all] Error 2
I don't have any idea about the error. I tried using google but i can't seem to find similar problems like mine.
The usual reason for this error is that you've compiled against android-23 or higher but are linking against something earlier. Another variation of that issue is when you have multiple libraries built against different API levels.
It looks like you are using a standalone toolchain? If that's correct, then I'd suspect your issue is either a prebuilt library that's part of libcurses (FWIR there aren't any of those, so unlikely) or that there's something funky going on in their build scripts that causes one of the two issues I mentioned. Tons of projects add their own Android specific hacks to their build scripts that always end up being the cause of these sorts of issues, so that wouldn't surprise me at all.
Should look at both the compilation command for tic.c and the link command for whatever library/executable is failing to link there. Make sure both are using the same API levels (look for things like $NDK/platforms/android-$API_LEVEL, -D__ANDROID_API__=$API_LEVEL, and -target arm-linux-androideabi$API_LEVEL).
btw, not ncurses 6, but I do have an example showing how to use standalone toolchains that had to build ncurses 5.9: https://github.com/DanAlbert/lua-ndk/blob/master/build_lua_with_libreadline.sh#L75. Might be worth taking a look to see if that helps at all.

crystax ndk link error

I'm trying to build poco and cegui libs with crystax ndk(version 10.3.2) using cmake
export ANDROID_NDK=/.../crystax-ndk-10.3.2
cmake -DPOCO_STATIC=ON -DCMAKE_TOOLCHAIN_FILE="../../AndroidBuildToolchain/android.toolchain.cmake" -DANDROID_ABI=x86 -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_TOOLCHAIN_NAME=x86-4.9 ../..
and build my own app with android.mk and I got the same error(using ndk-build):
crystax-ndk-10.3.2/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld: error: cannot find -lcrystax
And other link errors from, like these
error: undefined reference to 'sinf'
error: undefined reference to 'cosf'
error: undefined reference to '__getCurrentRuneLocale'
But when i'm trying to build the poco and my project with google NDK it works good. But I have reasons to use crystax. So, can anybody help me to find out the reason of these errors?
I've tried -lm flag for math(sin,cos) lib, but I had the same errors.

GStreamer "undefined reference to '__srget'"

I have troubles to run the GStreamer tutorials. I followed all tutorial steps, and run into an error.
My System:
android-ndk-r11c, gstreamer-sdk-android-arm-debug-2013.6
My System: Windows 10 - 64 bit
The Error:
C:\gstreamer-sdk-android-arm-debug-2013.6\share\gst-sdk\tutorials\android-tutorial-1>ndk-build
GStreamer : [GEN] => gst-build/gstreamer_android.c
GStreamer : [COMPILE] => gst-build/gstreamer_android.c
GStreamer : [LINK] => gst-build/libgstreamer_android.so
lex.priv_gst_parse_yy.c:1598: error: undefined reference to '__srget'
gutils.c:2406: error: undefined reference to 'issetugid'
localcharset.c:158: error: undefined reference to '__srget'
localcharset.c:167: error: undefined reference to '__srget'
./localcharset.c:195: error: undefined reference to '__srget'
/home/slomo/Projects/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.7/include-fixed/stdio.h:376: error: undefined reference to '__swbuf'
collect2.exe: error: ld returned 1 exit status
make: *** [buildsharedlibrary] Error 1
C:\gstreamer-sdk-android-arm-debug-2013.6\share\gst-sdk\tutorials\android-tutorial-1>
I tried:
Windows linkage problems : Due to problems related to the standard linker, Google’s Gold Linker is used to build GStreamer applications. Unfortunately, the Android NDK toolchain for Windows does not include the gold linker and the standard one has to be used.
If you observe linkage problems, you can replace the linker in your Android NDK with the gold one from this project. Download the android-ndk-r8b-ma-windows.7z file, extract \android-ndk-r8b\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\arm-linux-androideabi\bin\ld.exe (only this file is needed) and overwrite the one in the same folder in your Android NDK installation.
No effect. Any ideas how to solve this?
I had similar problem before please give a try with ndk10b.It is always good to check in header files for __srget before move forward.

aosp_x86-eng build on AOSP 4.3 source code is failing with error __strlen_chk

I am trying to build the x86 image on AOSP 4.3 source code.
followed below steps:
source build/envsetup.sh
lunch ( selected aosp_x86-eng)
make -j4
It gives below error.
bionic/libc/include/string.h:219: error: undefined reference to '__strlen_chk'
bionic/libc/include/string.h:219: error: undefined reference to '__strlen_chk'
bionic/libc/include/string.h:219: error: undefined reference to '__strlen_chk'
bionic/libc/include/string.h:219: error: undefined reference to '__strlen_chk'
Question:
It the steps for building x86 in AOSP 4.3 is correct?
How we can fix the above error.
I've solved it when building libcurl. The key idea is setting D_FORTIFY_SOURCE=0 in flags to disable checks, as mentioned in the source code.
LOCAL_STATIC_LIBRARIES += libc

Android - error: undefined reference to 'vtable for __cxxabiv1::__si_class_type_info'

Ok, I give up...
I've been trying to compile android's 4.x (x>=1) webkit to bypass the 4.0 bugs.
After a few compilations, of the libwebcore with correct bindings and different namespace, and android.webkit with different namespace and some code fixes to match 4.0 - it compiles, and works, on Android 4.3.
Additional problems came in when trying to run it on 4.0-4.2 - where I found out the libicuuc is incompatible between versions, as versioning occurs in the function names. So the solution is theoretically simple - compile libicuuc statically into the libwebcore, by adding LOCAL_STATIC_LIBRARIES += libicuuc to the Android.mk
This is where hell began: I get errors like error: undefined reference to 'vtable for __cxxabiv1::__si_class_type_info' and error: undefined reference to '__dynamic_cast'.
I tried adding LOCAL_RTTI_FLAG := -frtti but it didn't change anything.
Any ideas?
Thanks!

Categories

Resources