Skip to content

Compilation of earthtrack fails on Debian 11 'Bullseye' #17

@lrowen

Description

@lrowen
lowen@lowen-7740:~/development/predict/predict-2.3.0/clients/earthtrack$ gcc --version
gcc (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Using the default build script in the 2.3.0 distribution, I get the following error:

lowen@lowen-7740:~/development/predict/predict-2.3.0/clients/earthtrack$ ./build
Compiling earthtrack... /usr/bin/ld: /tmp/cckldGDS.o: in function `arccos':
earthtrack.c:(.text+0x32a): undefined reference to `acos'
/usr/bin/ld: earthtrack.c:(.text+0x359): undefined reference to `acos'
/usr/bin/ld: /tmp/cckldGDS.o: in function `rangecircle':
earthtrack.c:(.text+0x4ce): undefined reference to `sincos'
/usr/bin/ld: earthtrack.c:(.text+0x4f7): undefined reference to `sincos'
/usr/bin/ld: earthtrack.c:(.text+0x536): undefined reference to `cos'
/usr/bin/ld: earthtrack.c:(.text+0x54c): undefined reference to `asin'
/usr/bin/ld: earthtrack.c:(.text+0x55d): undefined reference to `sincos'
/usr/bin/ld: earthtrack.c:(.text+0x5f5): undefined reference to `acos'
/usr/bin/ld: earthtrack.c:(.text+0x83b): undefined reference to `acos'
collect2: error: ld returned 1 exit status
earthtrack compilation failed!  :-(

Changing the compile line in the build script from:
cc -O3 -s -fomit-frame-pointer -lm earthtrack.c -o earthtrack
to
cc -O3 -s -fomit-frame-pointer earthtrack.c -o earthtrack -lm
fixed the issue.

From the gcc link options page:

-llibrary
-l library
...
It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, ‘foo.o -lz bar.o’ searches library ‘z’ after file foo.o but before bar.o. If bar.o refers to functions in ‘z’, those functions may not be loaded.

So the -lm needs to come last in the line, with 'modern' gcc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions