Error When Cross-Compiling with Android NDK

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
vhmth
Posts: 13
Joined: 2014-02-06T15:49:55-07:00
Authentication code: 6789

Error When Cross-Compiling with Android NDK

Post by vhmth » 2014-03-25T02:35:41-07:00

Hey all. I'm currently cross-compiling all ImageMagick delegate libs with no problem using the Android NDK. However, when I try to do so with IM itself, I'm getting the error "configure: error: cannot run test program while cross compiling". Any ideas?

Code: Select all

[ 90%] Performing configure step for 'ImageMagick'
cd /home/opsteam/vinay/3rdparty/ImageMagick/ImageMagick-6.8.7-8 && env CC=/usr/local/android-ndk-r9-clang/bin/clang "CFLAGS=-O3 -g -DNDEBUG -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -D__ANDROID__ -g -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fno-strict-aliasing -Wa,--noexecstack -Wl,--fix-cortex-a8 -fPIC" AR=/usr/local/android-ndk-r9-clang//bin/arm-linux-androideabi-ar RANLIB=/usr/local/android-ndk-r9-clang//bin/arm-linux-androideabi-ranlib "CFLAGS=-O3 -g -DNDEBUG -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -D__ANDROID__ -g -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fno-strict-aliasing -Wa,--noexecstack -Wl,--fix-cortex-a8 -fPIC" "CXXFLAGS=-O3 -g -DNDEBUG -std=c++11 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -D__ANDROID__ -g -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fno-strict-aliasing -Wa,--noexecstack -Wl,--fix-cortex-a8" CPPFLAGS=-I/home/opsteam/vinay/3rdparty/ImageMagick/dist/ImageMagick/include LDFLAGS=-L/home/opsteam/vinay/3rdparty/ImageMagick/dist/ImageMagick/linux "LIBS=-ljpeg -lz -lpng" ./configure --host=arm-linux-androideabi --enable-static --disable-shared --disable-installed --prefix=/home/opsteam/vinay/3rdparty/ImageMagick/build/ImageMagick --without-bzlib --without-djvu --without-dps --without-fftw --without-fpx --without-fontconfig --without-freetype --without-jbig --without-jp2 --without-lcms --without-lcms2 --without-lqr --without-lzma --without-magick-plus-plus --without-openexr --without-pango --without-perl --without-tiff --without-webp --without-x --without-xml
configuring ImageMagick 6.8.7-8
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-androideabi
checking target system type... arm-unknown-linux-androideabi
checking whether build environment is sane... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for arm-linux-androideabi-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for arm-linux-androideabi-gcc... /usr/local/android-ndk-r9-clang/bin/clang
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 /usr/local/android-ndk-r9-clang/bin/clang accepts -g... yes
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO C89... none needed
checking whether /usr/local/android-ndk-r9-clang/bin/clang understands -c and -o together... yes
checking dependency style of /usr/local/android-ndk-r9-clang/bin/clang... gcc3
checking how to run the C preprocessor... /usr/local/android-ndk-r9-clang/bin/clang -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -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 minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for arm-linux-androideabi-gcc... (cached) /usr/local/android-ndk-r9-clang/bin/clang
checking whether we are using the GNU C compiler... (cached) yes
checking whether /usr/local/android-ndk-r9-clang/bin/clang accepts -g... (cached) yes
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO C89... (cached) none needed
checking whether /usr/local/android-ndk-r9-clang/bin/clang understands -c and -o together... (cached) yes
checking dependency style of /usr/local/android-ndk-r9-clang/bin/clang... (cached) gcc3
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/local/android-ndk-r9-clang//bin/clang++ accepts -g... yes
checking dependency style of /usr/local/android-ndk-r9-clang//bin/clang++... gcc3
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO C99... none needed
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO Standard C... (cached) none needed
checking how to run the C preprocessor... /usr/local/android-ndk-r9-clang/bin/clang -E
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking how to print strings... printf
checking for ld used by /usr/local/android-ndk-r9-clang/bin/clang... /usr/local/android-ndk-r9-clang/arm-linux-androideabi/bin/ld
checking if the linker (/usr/local/android-ndk-r9-clang/arm-linux-androideabi/bin/ld) is GNU ld... yes
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO C99... (cached) none needed
checking CFLAGS for maximum warnings... -Wall
checking whether make sets $(MAKE)... (cached) yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... (cached) /bin/sed
checking for gawk... (cached) mawk
checking if malloc debugging is wanted... no
checking for __attribute__... yes
checking for gcc architecture flag...
checking for gcc architecture flag... unknown
checking for arm-linux-androideabi-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.9.0... yes
checking if LD -Wl,--version-script works... yes
checking size of size_t... 4
checking for C compiler vendor... clang
checking CFLAGS for maximum warnings... (cached) -Wall
checking for linker lazyload option... none
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... no
checking for /usr/local/android-ndk-r9-clang/bin/clang option to support OpenMP... unsupported
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... (cached) 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 _LARGEFILE_SOURCE value needed for large files... no
checking for native large file support... configure: error: in `/home/opsteam/vinay/3rdparty/ImageMagick/ImageMagick-6.8.7-8':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
make[6]: *** [ImageMagick-prefix/src/ImageMagick-stamp/ImageMagick-configure] Error 1
make[6]: Leaving directory `/home/opsteam/vinay/3rdparty/ImageMagick'
make[5]: *** [CMakeFiles/ImageMagick.dir/all] Error 2
make[5]: Leaving directory `/home/opsteam/vinay/3rdparty/ImageMagick'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/home/opsteam/vinay/3rdparty/ImageMagick'
make[3]: *** [ImageMagick-prefix/src/ImageMagick-stamp/ImageMagick-build] Error 2
make[3]: Leaving directory `/home/opsteam/vinay/3rdparty/build/android'
make[2]: *** [CMakeFiles/ImageMagick.dir/all] Error 2
make[2]: Leaving directory `/home/opsteam/vinay/3rdparty/build/android'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/opsteam/vinay/3rdparty/build/android'
make: *** [android] Error 2

vhmth
Posts: 13
Joined: 2014-02-06T15:49:55-07:00
Authentication code: 6789

Re: Error When Cross-Compiling with Android NDK

Post by vhmth » 2014-03-25T13:01:36-07:00

Bump? This seems to happen for any cross-compilation.

User avatar
magick
Site Admin
Posts: 10980
Joined: 2003-05-31T11:32:55-07:00

Re: Error When Cross-Compiling with Android NDK

Post by magick » 2014-03-25T13:15:47-07:00

See viewtopic.php?f=3&t=25274. There was success cross-compiling ImageMagick for iOS.

vhmth
Posts: 13
Joined: 2014-02-06T15:49:55-07:00
Authentication code: 6789

Re: Error When Cross-Compiling with Android NDK

Post by vhmth » 2014-03-25T14:03:13-07:00

Thanks for the link! After looking through it, it seems like the issue the OP was facing is not the same issue I am facing. I am simply seeing the error of "cannot run test program while cross compiling". When I leave out the "--host=..." flag, it gives me the error:

Code: Select all

checking whether we are cross compiling... configure: error: in `/home/opsteam/vinay/3rdparty/ImageMagick/ImageMagick-6.8.8-9':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
After reading that thread, I tried updating IM to the latest (6.8.8-9), but I'm getting the same results. Has anyone else noticed this error? It seems like this page has a list of libraries that do/do not work when cross-compiling, and the same error is being reported there:

http://git.uclibc.org/buildroot/tree/sc ... 52f93cb11e

If it helps, here's the entire output of the configure:

Code: Select all

[ 90%] Performing configure step for 'ImageMagick'
configure: WARNING: unrecognized options: --without-jp2
configuring ImageMagick 6.8.8-9
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-linux-eabi
checking target system type... arm-linux-eabi
checking whether build environment is sane... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for arm-linux-eabi-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for arm-linux-eabi-gcc... /usr/local/android-ndk-r9-clang/bin/clang
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 /usr/local/android-ndk-r9-clang/bin/clang accepts -g... yes
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO C89... none needed
checking whether /usr/local/android-ndk-r9-clang/bin/clang understands -c and -o together... yes
checking dependency style of /usr/local/android-ndk-r9-clang/bin/clang... gcc3
checking how to run the C preprocessor... /usr/local/android-ndk-r9-clang/bin/clang -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -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 minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for arm-linux-eabi-gcc... (cached) /usr/local/android-ndk-r9-clang/bin/clang
checking whether we are using the GNU C compiler... (cached) yes
checking whether /usr/local/android-ndk-r9-clang/bin/clang accepts -g... (cached) yes
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO C89... (cached) none needed
checking whether /usr/local/android-ndk-r9-clang/bin/clang understands -c and -o together... (cached) yes
checking dependency style of /usr/local/android-ndk-r9-clang/bin/clang... (cached) gcc3
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/local/android-ndk-r9-clang//bin/clang++ accepts -g... yes
checking dependency style of /usr/local/android-ndk-r9-clang//bin/clang++... gcc3
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO C99... none needed
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO Standard C... (cached) none needed
checking how to run the C preprocessor... /usr/local/android-ndk-r9-clang/bin/clang -E
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking how to print strings... printf
checking for ld used by /usr/local/android-ndk-r9-clang/bin/clang... /usr/local/android-ndk-r9-clang/arm-linux-androideabi/bin/ld
checking if the linker (/usr/local/android-ndk-r9-clang/arm-linux-androideabi/bin/ld) is GNU ld... yes
checking for /usr/local/android-ndk-r9-clang/bin/clang option to accept ISO C99... (cached) none needed
checking CFLAGS for maximum warnings... -Wall
checking whether make sets $(MAKE)... (cached) yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... (cached) /bin/sed
checking for gawk... (cached) mawk
checking if malloc debugging is wanted... no
checking for __attribute__... yes
checking for gcc architecture flag...
checking for gcc architecture flag... unknown
checking for arm-linux-eabi-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.9.0... yes
checking if LD -Wl,--version-script works... yes
checking size of size_t... 4
checking for C compiler vendor... clang
checking CFLAGS for maximum warnings... (cached) -Wall
checking for linker lazyload option... none
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... no
checking for /usr/local/android-ndk-r9-clang/bin/clang option to support OpenMP... unsupported
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... (cached) 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 _LARGEFILE_SOURCE value needed for large files... no
checking for native large file support... configure: error: in `/home/opsteam/vinay/3rdparty/ImageMagick/ImageMagick-6.8.8-9':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
make[6]: *** [ImageMagick-prefix/src/ImageMagick-stamp/ImageMagick-configure] Error 1
make[6]: Leaving directory `/home/opsteam/vinay/3rdparty/ImageMagick'
make[5]: *** [CMakeFiles/ImageMagick.dir/all] Error 2
make[5]: Leaving directory `/home/opsteam/vinay/3rdparty/ImageMagick'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/home/opsteam/vinay/3rdparty/ImageMagick'
make[3]: *** [ImageMagick-prefix/src/ImageMagick-stamp/ImageMagick-build] Error 2
make[3]: Leaving directory `/home/opsteam/vinay/3rdparty/build/android'
make[2]: *** [CMakeFiles/ImageMagick.dir/all] Error 2
make[2]: Leaving directory `/home/opsteam/vinay/3rdparty/build/android'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/opsteam/vinay/3rdparty/build/android'
make: *** [android] Error 2

bindesh
Posts: 1
Joined: 2016-03-12T02:45:10-07:00
Authentication code: 1151

Re: Error When Cross-Compiling with Android NDK

Post by bindesh » 2016-03-12T02:54:38-07:00

Hi vhmth,

I tried to build ImageMagick using Android.mk files but it takes a lot of time to set flags of various kind when version changes. Therefore i created a script for cross-compilation using configure script as you are doing. However i see your log it says some problem after trying large file support. 64 Bit long addresses. Try disabling largefile by adding flag --disable-largefile.

I am sharing my script via my website's article. Please take a look if it helps you. Do let me know the results using the script. I will update my script and article if required. The script disables many features to let library work on most of Android devices. It does not build Magick++.

I have build old versions and latest ImageMagick-6.9.3-2 using this configure script.

http://www.ourinnovativemind.in/2016/03 ... -with.html
http://www.ourinnovativemind.blogspot.c ... -with.html

I have also built GraphicsMagick if you are interested.
http://www.ourinnovativemind.in/2016/03 ... using.html

Post Reply