subsurface-mobile build error undefined reference to 'rand'

Lubomir I. Ivanov neolit123 at
Sun Jun 18 13:06:10 PDT 2017

On 17 June 2017 at 06:54, Rick Walsh <rickmwalsh at> wrote:
> Hi,
> It turns out I might actually have a little bit of time to dedicate to
> Subsurface over the next couple of weeks, and I thought I'd start by
> reviving my Android build chain.  Running packaging/android/, I get
> stuck with this error.  Does anyone smarter than me know what's going on?
> I'm on Fedora 25, with android-ndk-r13b and Qt5.9.
> $ sh packaging/android/


> /home/rick/src/subsurface/libgit2-0.24.1/src/cache.c:117: error: undefined
> reference to 'rand'

sounds like it isn't linking against the platform libc.a. i doubt that
rand() is missing in the standard library implementation...maybe
wrapping another function but not missing.

you can try:

to see what the linker is doing.

i haven't tried the Subsurface Android build script, but i get
something like the bellow from the "ndk-build" script when building a
generic test library:

.exe -Wl,-soname, -shared
atforms/android-19/arch-arm testtest.o -lgcc  -gcc-toolchain c:/bin/
64 -no-canonical-prefixes -target armv7-none-linux-androideabi -Wl,--fix-cortex-
a8  -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
 -Wl,--warn-shared-textrel -Wl,--fatal-warnings    -lc -lm -o

it tells me that it sets the platform location correctly (--sysroot)
and it links against -lc (rand()) should be part libc.a and
it also sets the toolchain correctly (-gcc-toolchain) and -lgcc is
located in there.


More information about the subsurface mailing list