Tistory View
I just need a http downloader to use on android NDK, also ssl is not required on my app.
so. I Search prebuilt curl library in google. but, most compiled version are not matched on my app. something conflict OpenSSL, something not works, and so on. After all, I decide to compile curl source code to use on my app.
How to compile the curl source code.
Below link explains How to compile, android compiling also explained. but Its explaination is mismatched to my ndk version
https://curl.se/docs/install.html
So, I modified "exports" from above links. I tried compiling, and it produced libcurl.a files.
Error on My App.
First. I encountered error message while linking my app like below.
libcurl.a(libcurl_la-mprintf.o):mprintf.c:function curl_mprintf: error: undefined reference to 'stdout'
libcurl.a(libcurl_la-multi.o):multi.c:function curl_multi_fdset: error: undefined reference to '__FD_SET_chk'
libcurl.a(libcurl_la-url.o):url.c:function Curl_init_userdefined: error: undefined reference to 'stdin'
libcurl.a(libcurl_la-url.o):url.c:function Curl_init_userdefined: error: undefined reference to 'stderr'
libcurl.a(libcurl_la-if2ip.o):if2ip.c:function Curl_if2ip: error: undefined reference to 'getifaddrs'
libcurl.a(libcurl_la-if2ip.o):if2ip.c:function Curl_if2ip: error: undefined reference to 'freeifaddrs'
libcurl.a(libcurl_la-netrc.o):netrc.c:function parsenetrc: error: undefined reference to 'fgets_unlocked'
std* is not found... hm.. and What is getifaddrs...
I found this error was caused by compiler api version 29, my app is started from api 19. so I changed android compiler version to api21, [below api21 compilers are not exist in "android-ndk-r21"]. I retried with api21 ndk compiler.
Second, I encountered error messages while linking my app like below. TOO.... hm..
libcurl.a(libcurl_la-multi.o):multi.c:function curl_multi_fdset: error: undefined reference to '__FD_SET_chk'
"Standard in-out-error" relative error messages were eliminated, but I still got error on my app[minAPI 19].
__FD_SET_chk function(?) is introduced in API 21. api 19 devices have no this function.
If You change minSkVersion to 21 or higher, above error messages will be eliminated.
Modify to work on below API 21
I modified multi.c file in lib path on source code.
lib/multi.c : line 1061 and 1068
From..........
FD_SET(sockbunch[i], read_fd_set);
Replace With.........
__FDS_BITS(fd_set*,read_fd_set)[__FDELT(sockbunch[i])] |= __FDMASK(sockbunch[i]);
line 1068 is write_fd_set
FD_SET is defined in header <select.h>
#define __FD_SET(fd, set) (__FDS_BITS(fd_set*,set)[__FDELT(fd)] |= __FDMASK(fd))
Recompile and Test... Yes It works.
Download
I attached prebuilt curl libraries in this article Two versions, one is api21 or higher, and Other is below api21
Below api21 version. NOSSL (Modified version)
This files was tested on below devices.
Galaxy Note4 armeabi-v7a 32bits api23
Galaxy S6 Edge arm64-v8a 64bits api24
Chinese Intel android x86 32bits api19
LD player 64bits(emulater) x86_64 64bits api25?
API 21 or higher, NOSSL (Not Modified)
API 21 or higher with OpenSSL
Not modified with SSL Version, These Files are not tested. But maybe works..
OpenSSL for below API 21(Modified)
This Files are required for linking above curl
64bit files are for API21 in this File. Don't warry 64bit android were introduce in 2019(?), so most 64bit device versions are equal or higher than API-21
"Configure" results in my case
Compile machine : Ubuntu 20.04.2 LTS/64bits on virtual machine.
Host setup: aarch64-unknown-linux-android
Install prefix: /usr/local
Compiler: ~~~~~/android_ndk/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang
CFLAGS: -Qunused-arguments -Os
CPPFLAGS:
LDFLAGS:
LIBS: -lz
curl version: 7.80.0
SSL: no (--with-{openssl,gnutls,nss,mbedtls,wolfssl,schannel,secure-transport,mesalink,amissl,bearssl,rustls} )
SSH: no (--with-{libssh,libssh2})
zlib: enabled
brotli: no (--with-brotli)
zstd: no (--with-zstd)
GSS-API: no (--with-gssapi)
GSASL: no (libgsasl not found)
TLS-SRP: no (--enable-tls-srp)
resolver: POSIX threaded
IPv6: enabled
Unix sockets: enabled
IDN: no (--with-{libidn2,winidn})
Build libcurl: Shared=no, Static=yes
Built-in manual: enabled
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
Code coverage: disabled
SSPI: no (--enable-sspi)
ca cert bundle: no
ca cert path:
ca fallback:
LDAP: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS: no (--enable-ldaps)
RTSP: enabled
RTMP: no (--with-librtmp)
PSL: no (libpsl not found)
Alt-svc: enabled (--disable-alt-svc)
HSTS: no (--enable-hsts)
HTTP1: enabled (internal)
HTTP2: no (--with-nghttp2, --with-hyper)
HTTP3: no (--with-ngtcp2, --with-quiche)
ECH: no (--enable-ech)
Protocols: DICT FILE FTP GOPHER HTTP IMAP MQTT POP3 RTSP SMTP TELNET TFTP
Features: AsynchDNS IPv6 Largefile UnixSockets alt-svc libz
Compile command
example for armeabi-v7a
export NDK=~/android_ndk/android-ndk-r21
export HOST_TAG=linux-x86_64
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
export AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar
export AS=$TOOLCHAIN/bin/arm-linux-androideabi-as
export CC=$TOOLCHAIN/bin/armv7a-linux-androideabi21-clang
export CXX=$TOOLCHAIN/bin/armv7a-linux-androideabi21-clang++
export LD=$TOOLCHAIN/bin/arm-linux-androideabi-ld
export RANLIB=$TOOLCHAIN/bin/arm-linux-androideabi-ranlib
export STRIP=$TOOLCHAIN/bin/arm-linux-androideabi-strip
./configure --host aarch64-linux-android --with-pic --disable-shared --without-ssl
Source code
SSL Version NOTE
By below error
undefined reference to `UI_OpenSSL'
I add compile flag like below.
export CFLAGS=-DOPENSSL_NO_UI_CONSOLE
'Android Develop > helper' 카테고리의 다른 글
안드로이드 Native에서 Choreographer 사용하기 (0) | 2021.04.07 |
---|---|
안드로이드 Choreographer 사용하기 (1) | 2021.03.31 |
안드로이드 byte배열을 String 한글 변환(+charsetDecoder) (0) | 2020.12.30 |
Buffer(ByteBuffer, CharBuffer...) flip, compact, clear사용법 (0) | 2020.12.30 |
안드로이드 HttpUrlConnection POST 전송 #2 (3) | 2020.12.25 |
- Total
- Today
- Yesterday
- 공유 컨텍스트
- 티스토리
- 재테크
- TTS
- 전기요금
- OpenGL ES
- 에어콘
- 컴퓨트쉐이더
- 금리
- 전기료
- 재태크
- 아끼는 법
- 전기세
- 안드로이드
- Android
- choreographer
- gpgpu
- 적금
- 텍스처
- 예금
- 에어컨
- 애드핏
- 경제보복
- 컴퓨트셰이더
- 블로그
- 애드센스
- ComputeShader
- 사용료
- texture
- OpenGLes
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |