Building openssl with Android ndk r7

379 views
Skip to first unread message

Brandon Haugen

unread,
Nov 17, 2011, 12:25:13 PM11/17/11
to android-ndk
Trying to build openssl with the android ndk r7 fails linking :

shlib_target=; if [ -n "" ]; then \
shlib_target="linux-shared"; \
fi; \
LIBRARIES="-L.. -lssl -L.. -lcrypto" ; \
make -f ../Makefile.shared -e \
APPNAME=openssl OBJECTS="openssl.o verify.o asn1pars.o req.o dgst.o
dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o
crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o
gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o
s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o
pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o
rand.o engine.o ocsp.o prime.o ts.o" \
LIBDEPS=" $LIBRARIES -L/opt/android-ndk-r7/platforms/android-5/arch-
arm/usr/lib -lc -ldl" \
link_app.${shlib_target}
( :; LIBDEPS="${LIBDEPS:--L.. -lssl -L.. -lcrypto -L/opt/android-ndk-
r7/platforms/android-5/arch-arm/usr/lib -lc -ldl}"; LDCMD="${LDCMD:-
arm-linux-androideabi-gcc}"; LDFLAGS="${LDFLAGS:--DOPENSSL_THREADS -
D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DANDROID -fno-short-
enums -nostdlib -I/opt/android-ndk-r7/platforms/android-5/arch-arm/usr/
include -DTERMIO -O3 -fomit-frame-pointer -Wall}"; LIBPATH=`for x in
$LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`;
LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:
$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o
verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o
errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o
ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o
s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o
version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o
pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o
prime.o ts.o ${LIBDEPS} )
/opt/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/
darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-
linux-androideabi/bin/ld: warning: cannot find entry symbol _start;
defaulting to 0000ddf4
speed.o: In function `do_multi':
speed.c:(.text+0x7c4): undefined reference to `__aeabi_dadd'
speed.c:(.text+0x8e8): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0x900): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0x910): undefined reference to `__aeabi_dadd'
speed.c:(.text+0x924): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0x978): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0x990): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0x9a0): undefined reference to `__aeabi_dadd'
speed.c:(.text+0x9b4): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0xd84): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0xd9c): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0xdac): undefined reference to `__aeabi_dadd'
speed.c:(.text+0xdc0): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0x1144): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0x115c): undefined reference to `__aeabi_ddiv'
speed.c:(.text+0x116c): undefined reference to `__aeabi_dadd'
speed.c:(.text+0x1180): undefined reference to `__aeabi_ddiv'

There are a couple more undefined references later in the same file.

Building openssl with ndk r6b and before worked just fine though.

Configured with : ./Configure --cross-compile-prefix=arm-linux-
androideabi- linux-generic32 -DL_ENDIAN -DANDROID -fno-short-enums -
nostdlib \ -I$ANDROID_PLATFORM/arch-arm/usr/include -L
$ANDROID_PLATFORM/arch-arm/usr/lib -lc
where ANDROID_PLATFORM = /opt/android-ndk-r7/platforms/android-5

Any ideas?

David Turner

unread,
Nov 18, 2011, 5:04:49 AM11/18/11
to andro...@googlegroups.com
Your linker command is missing various necessary C runtime objects (e.g. crtbegin_so.o / crtend_so.o), as well as GCC runtime support library (e.g. -lgcc)
This probably comes from the fact that ${LDCMD} maps to the linker program (arm-linux-androideabi-ld) while it should be using the compiler driver instead (arm-linux-androideabi-gcc).

The toolchain was upgraded to binutils-2.20.1 for NDK r7, this probably explains why the linker is acting differently, but I would guess your configure script is buggy (quite common when cross-compiling projects), or not invoked with the right options (e.g. linux-generic32 looks suspicious).



--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Reply all
Reply to author
Forward
0 new messages