Hi,

I've got a few problems with Android, hopefully someone can give me some 
pointers. I've not done a huge amount of cross-compiling for android, but 
have built a few things successfully (libcurl with openSSL & C-ARES). Any 
help/pointers appreciated, cheers.

*tl;dr summary*
I can't get libuv compiled using gyp, and I can compile libuv using 
autotools, but make check fails and my test program doesn't function 
correctly if I use this binary.

*Long version*
I've been doing a bit of prototyping using libuv & libcurl. Thus far, I 
have my test program successfully running on iOS and I'm satisfied with it. 
I'm now trying to get it running on Android. I've run into problems, though.

*Development environment*
Firstly, my development / compile machine's env:
Mac mini, x86_64, OS X Yosemite 10.10.2 
Android NDK r10d, with native platform version=9

*Gyp:*
if I try to go the documented route and use gyp, the make stage fails.

*$ source ./android-configure 
> /Users/mark.simpson/Development/android-ndk-r10d gyp*
> Copying prebuilt binaries...
> Copying sysroot headers and libraries...
> Copying c++ runtime headers and libraries...
> Copying files to: 
> /Users/mark.simpson/built_software/libuv/android-toolchain
> Cleaning up...
> Done.
> ['-Dtarget_arch=arm', '-DOS=android', 
> '/Users/mark.simpson/built_software/libuv/uv.gyp', '-I', 
> '/Users/mark.simpson/built_software/libuv/common.gypi', '--depth=.', '-f', 
> 'make', '-Goutput_dir=/Users/mark.simpson/built_software/libuv/out', 
> '--generator-output', '/Users/mark.simpson/built_software/libuv/out', 
> '-Dhost_arch=x64', '-Duv_library=static_library', 
> '-Dcomponent=static_library']


The only modification I've made to the android-configure script is adding 
--stl=gnustil, and this is just so that the toolchain mirrors what I've 
used to build my other android libs. I've already cross-compiled libcurl & 
its dependencies and that's working fine. 


> *$ echo $PATH*
> /Users/mark.simpson/built_software/libuv/android-toolchain/bin:
> *rest_of_my_path*

 

>
> *$ make -C out* CC(target) 
> /Users/mark.simpson/built_software/libuv/out/Debug/obj.target/libuv/src/fs-poll.o
> arm-linux-androideabi-gcc: error: x86_64: No such file or directory
> arm-linux-androideabi-gcc: error: unrecognized command line option 
> '-fasm-blocks'
> arm-linux-androideabi-gcc: error: unrecognized command line option 
> '-mpascal-strings'
> arm-linux-androideabi-gcc: error: unrecognized command line option '-arch'
> make: *** 
> [/Users/mark.simpson/built_software/libuv/out/Debug/obj.target/libuv/src/fs-poll.o]
>  
> Error 1


After a brief chat on IRC, tjfontaine said it looks like gyp is getting 
confused and mixing in compile flags that aren't meant for this type of 
cross-compile. He also suggested that gyp sometimes struggles with 
cross-compile scenarios, and it would probably be a good bet to go the 
autotools route. Given that I know absolutely nothing about gyp, I went 
down the autotools route next.

*Autotools:*
When I go the autotools route, make runs without error, but make check 
fails and my test program doesn't function correctly.


> *$ sh autogen.sh*+ glibtoolize
> + aclocal -I m4
> + autoconf
> + automake --add-missing --copy 

*$ ./configure --build=x86_64-apple-darwin --host=arm-linux-androideabi 
> --with-sysroot=$ANDROID_SYSROOT --prefix 
> /Users/mark.simpson/built_software/libuv_compile/*
> checking for a BSD-compatible install... /usr/bin/install -c
> checking whether build environment is sane... yes
> checking for arm-linux-androideabi-strip... arm-linux-androideabi-strip
> checking for a thread-safe mkdir -p... ./install-sh -c -d
> checking for gawk... no
> checking for mawk... no
> checking for nawk... no
> checking for awk... awk
> checking whether make sets $(MAKE)... yes
> checking whether make supports nested variables... yes
> checking build system type... x86_64-apple-darwin
> checking host system type... arm-unknown-linux-androideabi
> checking for arm-linux-androideabi-gcc... arm-linux-androideabi-gcc
> checking whether the C compiler works... yes
> checking for C compiler default output file name... a.out
> checking for suffix of executables... 
> checking whether we are cross compiling... yes
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether arm-linux-androideabi-gcc accepts -g... yes
> checking for arm-linux-androideabi-gcc option to accept ISO C89... none 
> needed
> checking whether arm-linux-androideabi-gcc understands -c and -o 
> together... yes
> checking for style of include used by make... GNU
> checking dependency style of arm-linux-androideabi-gcc... gcc3
> checking if arm-linux-androideabi-gcc supports -fvisibility=hidden flag... 
> yes
> checking if arm-linux-androideabi-gcc supports -g flag... yes
> checking if arm-linux-androideabi-gcc supports -std=gnu89 flag... yes
> checking if arm-linux-androideabi-gcc supports -pedantic flag... yes
> checking if arm-linux-androideabi-gcc supports -Wall flag... yes
> checking if arm-linux-androideabi-gcc supports -Wextra flag... yes
> checking if arm-linux-androideabi-gcc supports -Wno-unused-parameter 
> flag... yes
> checking for arm-linux-androideabi-ar... arm-linux-androideabi-ar
> checking the archiver (arm-linux-androideabi-ar) interface... ar
> checking how to print strings... printf
> checking for a sed that does not truncate output... /usr/bin/sed
> checking for grep that handles long lines and -e... /usr/bin/grep
> checking for egrep... /usr/bin/grep -E
> checking for fgrep... /usr/bin/grep -F
> checking for ld used by arm-linux-androideabi-gcc... 
> /Users/mark.simpson/built_software/libuv/android-toolchain/arm-linux-androideabi/bin/ld
> checking if the linker 
> (/Users/mark.simpson/built_software/libuv/android-toolchain/arm-linux-androideabi/bin/ld)
>  
> is GNU ld... yes
> checking for BSD- or MS-compatible name lister (nm)... 
> /Users/mark.simpson/built_software/libuv/android-toolchain/bin/arm-linux-androideabi-nm
>  
> -B
> checking the name lister 
> (/Users/mark.simpson/built_software/libuv/android-toolchain/bin/arm-linux-androideabi-nm
>  
> -B) interface... BSD nm
> checking whether ln -s works... yes
> checking the maximum length of command line arguments... 196608
> checking how to convert x86_64-apple-darwin file names to 
> arm-unknown-linux-androideabi format... func_convert_file_noop
> checking how to convert x86_64-apple-darwin file names to toolchain 
> format... func_convert_file_noop
> checking for 
> /Users/mark.simpson/built_software/libuv/android-toolchain/arm-linux-androideabi/bin/ld
>  
> option to reload object files... -r
> checking for arm-linux-androideabi-objdump... arm-linux-androideabi-objdump
> checking how to recognize dependent libraries... pass_all
> checking for arm-linux-androideabi-dlltool... no
> checking for dlltool... no
> checking how to associate runtime and link libraries... printf %s\n
> checking for arm-linux-androideabi-ar... (cached) arm-linux-androideabi-ar
> checking for archiver @FILE support... @
> checking for arm-linux-androideabi-strip... (cached) 
> arm-linux-androideabi-strip
> checking for arm-linux-androideabi-ranlib... arm-linux-androideabi-ranlib
> checking command to parse 
> /Users/mark.simpson/built_software/libuv/android-toolchain/bin/arm-linux-androideabi-nm
>  
> -B output from arm-linux-androideabi-gcc object... ok
> checking for sysroot... 
> /Users/mark.simpson/Development/android-ndk-r10d/platforms/android-9/arch-arm
> checking for a working dd... /bin/dd
> checking how to truncate binary pipes... /bin/dd bs=4096 count=1
> checking for arm-linux-androideabi-mt... no
> checking for mt... no
> checking if : is a manifest tool... no
> checking how to run the C preprocessor... arm-linux-androideabi-gcc -E
> checking for ANSI C header files... yes
> checking for sys/types.h... yes
> checking for sys/stat.h... yes
> checking for stdlib.h... yes
> checking for string.h... yes
> checking for memory.h... yes
> checking for strings.h... yes
> checking for inttypes.h... yes
> checking for stdint.h... yes
> checking for unistd.h... yes
> checking for dlfcn.h... yes
> checking for objdir... .libs
> checking if arm-linux-androideabi-gcc supports -fno-rtti 
> -fno-exceptions... no
> checking for arm-linux-androideabi-gcc option to produce PIC... -fPIC -DPIC
> checking if arm-linux-androideabi-gcc PIC flag -fPIC -DPIC works... yes
> checking if arm-linux-androideabi-gcc static flag -static works... yes
> checking if arm-linux-androideabi-gcc supports -c -o file.o... yes
> checking if arm-linux-androideabi-gcc supports -c -o file.o... (cached) yes
> checking whether the arm-linux-androideabi-gcc linker 
> (/Users/mark.simpson/built_software/libuv/android-toolchain/arm-linux-androideabi/bin/ld)
>  
> supports shared libraries... yes
> checking whether -lc should be explicitly linked in... no
> checking dynamic linker characteristics... Android linker
> checking how to hardcode library paths into programs... immediate
> checking whether stripping libraries is possible... yes
> checking if libtool supports shared libraries... yes
> checking whether to build shared libraries... yes
> checking whether to build static libraries... yes
> checking whether make supports nested variables... (cached) yes
> checking for dlopen in -ldl... yes
> checking for kstat_lookup in -lkstat... no
> checking for kvm_open in -lkvm... no
> checking for gethostbyname in -lnsl... no
> checking for perfstat_cpu in -lperfstat... no
> checking for pthread_mutex_init in -lpthread... no
> checking for clock_gettime in -lrt... no
> checking for sendfile in -lsendfile... no
> checking for socket in -lsocket... no
> checking for special C compiler options needed for large files... no
> checking for _FILE_OFFSET_BITS value needed for large files... unknown
> checking for _LARGE_FILES value needed for large files... unknown
> checking for pkg-config... no
> checking that generated files are newer than configure... done
> configure: creating ./config.status
> config.status: creating Makefile
> config.status: executing depfiles commands
> config.status: executing libtool commands


*$ make*
>   CC       src/libuv_la-fs-poll.lo
>   CC       src/libuv_la-inet.lo
>   CC       src/libuv_la-threadpool.lo
>   CC       src/libuv_la-uv-common.lo
>   CC       src/libuv_la-version.lo
>   CC       src/unix/libuv_la-async.lo
>   CC       src/unix/libuv_la-core.lo
>   CC       src/unix/libuv_la-dl.lo
>   CC       src/unix/libuv_la-fs.lo
>   CC       src/unix/libuv_la-getaddrinfo.lo
>   CC       src/unix/libuv_la-getnameinfo.lo
>   CC       src/unix/libuv_la-loop-watcher.lo
>   CC       src/unix/libuv_la-loop.lo
>   CC       src/unix/libuv_la-pipe.lo
> src/unix/pipe.c: In function 'uv__pipe_getsockpeername':
> src/unix/pipe.c:237:15: warning: comparison between signed and unsigned 
> integer expressions [-Wsign-compare]
>    if (addrlen > *size) {
>                ^
>   CC       src/unix/libuv_la-poll.lo
>   CC       src/unix/libuv_la-process.lo
>   CC       src/unix/libuv_la-signal.lo
>   CC       src/unix/libuv_la-stream.lo
>   CC       src/unix/libuv_la-tcp.lo
>   CC       src/unix/libuv_la-thread.lo
>   CC       src/unix/libuv_la-timer.lo
>   CC       src/unix/libuv_la-tty.lo
>   CC       src/unix/libuv_la-udp.lo
>   CC       src/unix/libuv_la-android-ifaddrs.lo
> src/unix/android-ifaddrs.c: In function 'getNetlinkResponse':
> src/unix/android-ifaddrs.c:139:9: warning: implicit declaration of 
> function 'uv__free' [-Wimplicit-function-declaration]
>          uv__free(l_buffer);
>          ^
> src/unix/android-ifaddrs.c:140:9: warning: implicit declaration of 
> function 'uv__malloc' [-Wimplicit-function-declaration]
>          l_buffer = uv__malloc(l_size);
>          ^
> src/unix/android-ifaddrs.c:140:18: warning: assignment makes pointer from 
> integer without a cast [enabled by default]
>          l_buffer = uv__malloc(l_size);
>                   ^
> src/unix/android-ifaddrs.c: In function 'newListItem':
> src/unix/android-ifaddrs.c:185:27: warning: initialization makes pointer 
> from integer without a cast [enabled by default]
>      NetlinkList *l_item = uv__malloc(sizeof(NetlinkList));
>                            ^
> src/unix/android-ifaddrs.c: In function 'interpretLink':
> src/unix/android-ifaddrs.c:351:13: warning: assignment makes pointer from 
> integer without a cast [enabled by default]
>      l_entry = uv__malloc(sizeof(struct ifaddrs) + sizeof(int) + 
> l_nameSize + l_addrSize + l_dataSize);
>              ^
> src/unix/android-ifaddrs.c: In function 'interpretAddr':
> src/unix/android-ifaddrs.c:480:13: warning: assignment makes pointer from 
> integer without a cast [enabled by default]
>      l_entry = uv__malloc(sizeof(struct ifaddrs) + l_nameSize + 
> l_addrSize);
>              ^
>   CC       src/unix/libuv_la-pthread-fixes.lo
>   CC       src/unix/libuv_la-linux-core.lo
>   CC       src/unix/libuv_la-linux-inotify.lo
>   CC       src/unix/libuv_la-linux-syscalls.lo
>   CC       src/unix/libuv_la-proctitle.lo
>   CCLD     libuv.la


*$ make check*
lots of warnings like: 
test/task.h:80:13: warning: anonymous variadic macros were introduced in 
C99 [-Wvariadic-macros] (should I be specifying C99 somewhere?)

then...

*test/test-signal-multiple-loops.c:248: error: undefined reference to 
'uv__pthread_sigmask'*
collect2: error: ld returned 1 exit status
make[1]: *** [test/run-tests] Error 1
make: *** [check-am] Error 2

So basically, I'm a bit stumped now. Hopefully I'm just making some sort of 
newbie CC error. Any help appreciated.





-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to