[strongSwan] undefined reference to vstr functions while building strongswan for Android

Tobias Brunner tobias at strongswan.org
Sat Jul 13 10:02:50 CEST 2013

Hi Indu,

> /home/indu/adt/adt-bundle-linux-x86_64-20130522/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld:
> ./obj/local/armeabi/objs/strongswan/utils/printf_hook.o: in function
> vstr_fmt_add_handler:jni/strongswan/src/libstrongswan/utils/printf_hook.c:185:
> error: undefined reference to 'vstr_fmt_add'

This issue is related to the new x86_64 host toolchains that were
introduced with the 8e release of the NDK (which seems to be included in
the recent ADT bundle you are using).  If the x86 version of the NDK is
not also installed on the host the NDK script that should create the
standalone toolchain fails when not explicitly told to build an x86_64
toolchain (it simply defaults to building an x86 toolchain, which it
can't, instead of doing some kind of auto-detection).

Unfortunately, the vstr_arch.build script does not have much error
handling and, thus, did not notice that the toolchain was not there.
Instead it continued, but built the library with the tools on your
x86_64 host, that is, it did not cross-compile for ARM.  Therefore,
while the symbols are, in fact, contained in the libvstr.a archive it is
built for the wrong architecture.  This later causes the observed errors
when the linker tries to link libvstr.a (x86_64) into libstrongswan.so

I updated the build script on the wiki [1], so that the x86_64 toolchain
can now be used explicitly (there is no need to also install the x86
NDK, which requires a whole bunch of extra libraries - ia32-libs package
on Ubuntu - when used on x86_64 hosts).  I also added some error
handling if building the toolchain fails.


[1] http://wiki.strongswan.org/projects/strongswan/wiki/AndroidVPNClient

More information about the Users mailing list