subsurface-mobile build error undefined reference to 'rand'

Lubomir I. Ivanov neolit123 at gmail.com
Mon Jun 19 08:57:50 PDT 2017


On 19 June 2017 at 13:31, Rick Walsh <rickmwalsh at gmail.com> wrote:
>>
> Thanks for the tip.  Adding VERBOSE=1 to the command line didn't work as
> expected - it just silenced the output, but I added it to the make line
> within build.sh, and that provides some more useful output.  I can't find
> any reference to -lc, -gcc-toolchain, or -lgcc.
>

<snip>

> --sysroot=/home/rick/src/subsurface/ndk-arm/sysroot

go to that folder and investigate and grep / nm  for "rand" in both
the lib and include (if there are such under "usr").

lib $ grep rand * -rn
...
Binary file libc.a matches
Binary file libc.so matches

nm libc.a | grep rand
...

lrand48.o:
00000001 T lrand48 <--- in my case this is the one of interest (see note bellow)

> -lusb-1.0 -lxml2 -lsqlite3 -lxslt -lxml2 -lz -lm -lxml2 -lzip -lz -lusb-1.0

SIDENOTE: these appear to be added multiple times in the same linker
command line. not a great thing to have.

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

i've just checked my toolchain and it appears that rand() is inline defined as:

static __inline__ int rand(void) {
    return (int)lrand48();
}

go to the sysroot and see if that's the case for you in include/stdlib.h.

if that's the case the real symbol it should be looking for is lrand48
and not rand.
for me libc itself does not contain a "rand" symbol exactly, but the
*rand48 family.

so the above message makes no sense, unless libgit's cache.c is built
with a toolchain that doesn't have the above inline rand().

try clearing everything up and observe with verbose mode when libgit
is being built.
build.sh line 258 ---> add VERBOSE=1

lubomir
--


More information about the subsurface mailing list