CrossCompiling for Android

I am trying to compile LibRaw for android, but I am getting stuck.

I downloaded the ndk, setup a standalone toolchain for android-9, added that bin folder as first to my path,
and ran ./configure --host=arm-linux-androideabi

I did need to update the config.sub file since it was very old and did not recognize this host setting. After that it completely ran ./configure and I tried to run make.

Here it however failed fast:

LibRaw-0.14.4$ make
depbase=`echo internal/dcraw_common.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
	/bin/bash ./libtool --tag=CXX   --mode=compile arm-linux-androideabi-g++ -DPACKAGE_NAME=\"LibRaw\" -DPACKAGE_TARNAME=\"libraw\" -DPACKAGE_VERSION=\"0.14.4\" -DPACKAGE_STRING=\"LibRaw\ 0.14.4\" -DPACKAGE_BUGREPORT=\"<a href=""></a>\" -DPACKAGE_URL=\"<a href=""></a>\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I.   -I/usr/local/include  -g -O2 -MT internal/dcraw_common.lo -MD -MP -MF $depbase.Tpo -c -o internal/dcraw_common.lo internal/dcraw_common.cpp &&\
	mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  arm-linux-androideabi-g++ -DPACKAGE_NAME=\"LibRaw\" -DPACKAGE_TARNAME=\"libraw\" -DPACKAGE_VERSION=\"0.14.4\" "-DPACKAGE_STRING=\"LibRaw 0.14.4\"" -DPACKAGE_BUGREPORT=\"<a href=""></a>\" -DPACKAGE_URL=\"<a href=""></a>\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -I/usr/local/include -g -O2 -MT internal/dcraw_common.lo -MD -MP -MF internal/.deps/dcraw_common.Tpo -c internal/dcraw_common.cpp  -fPIC -DPIC -o internal/.libs/dcraw_common.o
internal/dcraw_common.cpp: In member function 'void LibRaw::read_shorts(ushort*, int)':
internal/dcraw_common.cpp:119: error: 'swab' was not declared in this scope
internal/dcraw_common.cpp: In member function 'void LibRaw::write_ppm_tiff()':
internal/dcraw_common.cpp:9235: error: 'swab' was not declared in this scope
make: *** [internal/dcraw_common.lo] Error 1

I don't understand what I am doing wrong. It fully compiled when I don't target android. Did anybody succeed in compiling this properly? What am I missing?


This error is also there when

This error is also there when I just use ndk-build on only the dcraw.c file.
Is android missing a library where this 'swab' function comes from?

Yes, added a simple missing

Yes, added a simple missing function of swab did made it compile.
However, when I try to use the lib on android, I keep getting link errors, since it still searches for internally. Android doesn't support the .5 extension, it needs to have a .so file. So this one doesn't load.

Is there an option to just output a .so file instead of having versioned ones?

Versioning is critical for

Versioning is critical for normal use of libraw because different versions are binary incompatible, so app using .so.4 should not link with .so.5 and vice versa.

You may consider static linking (and ./configure --static)

-- Alex Tutubalin @LibRaw LLC

Ok, thanks.

Ok, thanks.

peterdk, do you can show(or

peterdk, do you can show(or upload) you config.sub and configure? thanks!