1

i've created a script that compiles curl for android for 3 platforms, well more like 4: 1. armv5 2. armv7 3. x86 4. mips

i do it using this post in SO: enter link description here for arm and x86 everything works ok (i use ndk toolchains and openssl specific library which i compiled for those same platform beforehand). the only problematic platform is mips. i DO get the libcrul.a,la and .so BUT when trying to compile the executable curl the linkage fails:

libtool: link: mipsel-linux-android-gcc -O2 -Wno-system-headers -o .libs/curl curl-tool_binmode.o curl-tool_bname.o curl-tool_cb_dbg.o curl-tool_cb_hdr.o curl-tool_cb_prg.o curl-tool_cb_rea.o curl-tool_cb_see.o curl-tool_cb_wrt.o curl-tool_cfgable.o curl-tool_convert.o curl-tool_dirhie.o curl-tool_doswin.o curl-tool_easysrc.o curl-tool_formparse.o curl-tool_getparam.o curl-tool_getpass.o curl-tool_help.o curl-tool_helpers.o curl-tool_homedir.o curl-tool_hugehelp.o curl-tool_libinfo.o curl-tool_main.o curl-tool_metalink.o curl-tool_mfiles.o curl-tool_msgs.o curl-tool_operate.o curl-tool_operhlp.o curl-tool_panykey.o curl-tool_paramhlp.o curl-tool_parsecfg.o curl-tool_setopt.o curl-tool_sleep.o curl-tool_urlglob.o curl-tool_util.o curl-tool_vms.o curl-tool_writeenv.o curl-tool_writeout.o curl-tool_xattr.o ../lib/curl-strtoofft.o ../lib/curl-strdup.o ../lib/curl-rawstr.o ../lib/curl-nonblock.o ../lib/curl-warnless.o  -L/usr/local/android-ndk/platforms/android-9/arch-mips/usr/lib -L/home/eyal/devel/openssl/lib ../lib/.libs/libcurl.so -lz
/usr/local/ndk-toolchains/mipsel-linux-android-4.6/bin/../lib/gcc/mipsel-linux-android/4.6/../../../../mipsel-linux-android/bin/ld: warning: libssl.so.1.1.0, needed by ../lib/.libs/libcurl.so, not found (try using -rpath or -rpath-link)
/usr/local/ndk-toolchains/mipsel-linux-android-4.6/bin/../lib/gcc/mipsel-linux-android/4.6/../../../../mipsel-linux-android/bin/ld: warning: libcrypto.so.1.1.0, needed by ../lib/.libs/libcurl.so, not found (try using -rpath or -rpath-link)
../lib/.libs/libcurl.so: undefined reference to `RAND_load_file'
../lib/.libs/libcurl.so: undefined reference to `SSL_CTX_use_certificate'
../lib/.libs/libcurl.so: undefined reference to `X509_load_crl_file'
../lib/.libs/libcurl.so: undefined reference to `SSL_set_fd'
../lib/.libs/libcurl.so: undefined reference to `SSL_set_connect_state'
../lib/.libs/libcurl.so: undefined reference to `SSL_CTX_free'
../lib/.libs/libcurl.so: undefined reference to `X509_free'

there are more 'undefined reference' errors, i spared u... the library exists, the -L paths are ok, i checked, permission seems to be fine, and again, it works for both arm and x86 for android. i'm using --host=mipsel-linux-android which might be wrong, but seems like it's the right one, the .so and .a are built so something went alright, but ld for some reason can't locate ssl and crypt once it's requested when trying to create and executable.

Anyone has any idea ? when tryying to use the toolchain manually to compile a file using libssl i was successful!

10x.

Community
  • 1
  • 1
codeScriber
  • 4,582
  • 7
  • 38
  • 62
  • Do you perform MIPS testing on a real device? If so, which one? (I've been trying to locate a MIPS device for testing, but I can't find one in a US sales channel). – jww Sep 15 '14 at 18:46
  • we had a single device for that, it's in the malware research lab and it's been quite a long time since i used it so i can't recall the name, it's nice and pink :-) yeah, very little, close to non existing, mips devices around the market, i use MIPS android emulator for testing. put the executable in /data/local/ and run it. – codeScriber Sep 16 '14 at 08:57

1 Answers1

1

../lib/.libs/libcurl.so: undefined reference to `RAND_load_file'

These are OpenSSL functions. Do you have OpenSSL cross compiled for MIPS? If so, is it available?


libtool: link: mipsel-linux-android-gcc -O2 -Wno-system-headers -o .libs/curl curl-tool_binmode.o 
curl-tool_bname.o curl-tool_cb_dbg.o curl-tool_cb_hdr.o curl-tool_cb_prg.o curl-tool_cb_rea.o 
curl-tool_cb_see.o curl-tool_cb_wrt.o curl-tool_cfgable.o curl-tool_convert.o curl-tool_dirhie.o 
curl-tool_doswin.o curl-tool_easysrc.o curl-tool_formparse.o curl-tool_getparam.o 
curl-tool_getpass.o curl-tool_help.o curl-tool_helpers.o curl-tool_homedir.o curl-tool_hugehelp.o 
curl-tool_libinfo.o curl-tool_main.o curl-tool_metalink.o curl-tool_mfiles.o curl-tool_msgs.o 
curl-tool_operate.o curl-tool_operhlp.o curl-tool_panykey.o curl-tool_paramhlp.o 
curl-tool_parsecfg.o curl-tool_setopt.o curl-tool_sleep.o curl-tool_urlglob.o curl-tool_util.o 
curl-tool_vms.o curl-tool_writeenv.o curl-tool_writeout.o curl-tool_xattr.o ../lib/curl-strtoofft.o 
../lib/curl-strdup.o ../lib/curl-rawstr.o ../lib/curl-nonblock.o ../lib/curl-warnless.o 
 -L/usr/local/android-ndk/platforms/android-9/arch-mips/usr/lib -L/home/eyal/devel/openssl/lib 
../lib/.libs/libcurl.so -lz

OK... It looks like you specified the path to libcrypto and libssl:

-L/home/eyal/devel/openssl/lib

But it does not look like you passed in the actual libraries:

-lssl -lcrypto

I'm using --host=mipsel-linux-android which might be wrong...

This looks OK to me. Here's what the folks on the Autotools list told me to use for Android/ARM:

./configure --build=`./config.guess` --host=arm-linux-androideabi

I'd expect MIPS to use something like this because of what the Autotools folks passed on:

./configure --build=`./config.guess` --host=mipsel-linux-android

But I still think yours is OK.

jww
  • 97,681
  • 90
  • 411
  • 885
  • yes, i compiled the openssl for all the platforms i specified above, it supports them in it's Config perl script, i checked, i also double checked the .so libs with file libssl.so and saw it was indeed 32 bit mips binary., if you specify -L and you don't explicitly uses openssl function but your shared library (libcurl.so) uses the, it should find it automatically, and it does for arm and x86! just mips gives me a headache, BTW if i explicitly specify the path to an libssl and libcrypt, compilation passes. – codeScriber Sep 15 '14 at 05:50
  • For MIPS only i needed to add to LDFLAGS -lssl and -lcrypto for some reason. other archs did not need it, bug in the mips cross compile ld if u ask me. – codeScriber Sep 15 '14 at 09:20
  • @codeScriber the names of the openSSL libraries are not the same on every platform. -lssl and -lcrypto are the names of libraries produced by the openssl package under a unix like/variant platform if I recall correctly. –  Apr 26 '15 at 15:45