gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Once more: -static linking


From: rudolf
Subject: Re: Once more: -static linking
Date: Wed, 25 Oct 2023 20:13:29 +0200 (CEST)

Hi Gaius,

many thanks for this simple solution!


BR

Rudolf

--
Rudolf Schubert                 \
Kirchstr. 18a                    \  mailto:rudolf@muc.de
82054 Sauerlach                   > http://www.dose.muc.de
Deutschland                      /   (alpine archkiste)
Tel. 08104/908311               /


On Wed, 25 Oct 2023, Gaius Mulley wrote:

rudolf@muc.de writes:

Hi Gaius,

a few days ago I sent some 'example files' to you which show
my 'static linking problem'. Did the files reach you or were
you able to reproduce the problem?


Thanks

Rudolf

Hi Rudolf,

ah yes - many thanks!  I've just invesigated and it seems that there is
a missing -lm (in the gm2 driver - or that -lm needs to be repositioned
after all the m2 default libraries).  Ah actually I think that the -lm
should not be present on the command line.  For example:

$ gm2 -fiso -fsoft-check-all squash1.mod Ctv2.o unix.o -o squash1 -lc -lcrypt 
-lm -static
/usr/bin/ld: 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64/libm2iso.a(RealMath.o):
 in function `m2iso_RealMath_exp':
/home/gaius/GCC/gcc-read-write/build/x86_64-pc-linux-gnu/libgm2/libm2iso/../../../../libgm2/libm2iso/../../gcc/m2/gm2-libs-iso/RealMath.mod:41:
 undefined reference to `exp'
/usr/bin/ld: 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64/libm2iso.a(RealMath.o):
 in function `m2iso_RealMath_ln':
/home/gaius/GCC/gcc-read-write/build/x86_64-pc-linux-gnu/libgm2/libm2iso/../../../../libgm2/libm2iso/../../gcc/m2/gm2-libs-iso/RealMath.mod:47:
 undefined reference to `log'
/usr/bin/ld: 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64/libm2iso.a(RealMath.o):
 in function `m2iso_RealMath_sin':
/home/gaius/GCC/gcc-read-write/build/x86_64-pc-linux-gnu/libgm2/libm2iso/../../../../libgm2/libm2iso/../../gcc/m2/gm2-libs-iso/RealMath.mod:55:
 undefined reference to `sin'
/usr/bin/ld: 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64/libm2iso.a(RealMath.o):
 in function `m2iso_RealMath_cos':
/home/gaius/GCC/gcc-read-write/build/x86_64-pc-linux-gnu/libgm2/libm2iso/../../../../libgm2/libm2iso/../../gcc/m2/gm2-libs-iso/RealMath.mod:61:
 undefined reference to `cos'
/usr/bin/ld: 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64/libm2iso.a(RealMath.o):
 in function `m2iso_RealMath_tan':
/home/gaius/GCC/gcc-read-write/build/x86_64-pc-linux-gnu/libgm2/libm2iso/../../../../libgm2/libm2iso/../../gcc/m2/gm2-libs-iso/RealMath.mod:67:
 undefined reference to `tan'
/usr/bin/ld: 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64/libm2iso.a(RealMath.o):
 in function `m2iso_RealMath_arcsin':
/home/gaius/GCC/gcc-read-write/build/x86_64-pc-linux-gnu/libgm2/libm2iso/../../../../libgm2/libm2iso/../../gcc/m2/gm2-libs-iso/RealMath.mod:73:
 undefined reference to `asin'
/usr/bin/ld: 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64/libm2iso.a(RealMath.o):
 in function `m2iso_RealMath_arccos':
/home/gaius/GCC/gcc-read-write/build/x86_64-pc-linux-gnu/libgm2/libm2iso/../../../../libgm2/libm2iso/../../gcc/m2/gm2-libs-iso/RealMath.mod:79:
 undefined reference to `acos'
/usr/bin/ld: 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64/libm2iso.a(RealMath.o):
 in function `m2iso_RealMath_arctan':
/home/gaius/GCC/gcc-read-write/build/x86_64-pc-linux-gnu/libgm2/libm2iso/../../../../libgm2/libm2iso/../../gcc/m2/gm2-libs-iso/RealMath.mod:85:
 undefined reference to `atan'
/usr/bin/ld: 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64/libm2iso.a(RealMath.o):
 in function `m2iso_RealMath_power':
/home/gaius/GCC/gcc-read-write/build/x86_64-pc-linux-gnu/libgm2/libm2iso/../../../../libgm2/libm2iso/../../gcc/m2/gm2-libs-iso/RealMath.mod:91:
undefined reference to `pow'


The -lm will provoke gm2 to add the -lm library before the default
m2 libraries - resulting in the undefined references above.  If we run
the command line with:

$ gm2 -fiso -fsoft-check-all squash1.mod Ctv2.o unix.o -o squash1 -lc -lcrypt 
-lm -static -v

  ...

/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/collect2 -plugin \
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/liblto_plugin.so \
-plugin-opt=/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper \
-plugin-opt=-fresolution=/tmp/ccgJ1kSh.res \
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh \
-plugin-opt=-pass-through=-lc -m elf_x86_64 -static -o squash1 \
/lib/x86_64-linux-gnu/crt1.o /lib/x86_64-linux-gnu/crti.o \
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/crtbeginT.o \
-L/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0 \
-L/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../../../lib64 \
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu \
-L/usr/lib/../lib64 \
-L/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/../../.. /tmp/ccZt6UtL.o \
Ctv2.o unix.o -lc -lcrypt -lm -lm2iso -lm2cor -lm2pim -lm2log -lstdc++ \
             ^^^^^^^^^^^^^^^
-lpthread --start-group -lgcc -lgcc_eh -lc --end-group \
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.0/crtend.o \
/lib/x86_64-linux-gnu/crtn.o


the -lm is inserted prior to -lm2iso -lm2cor -lm2pim -lm2log and the
atan etc is unresolved.  If we omit the -lm then the gm2 driver adds -lm
as a default library (it always does this providing the host has a
-lm and it always places default libraries after user specified libraries).

$ gm2 -fiso -fsoft-check-all squash1.mod Ctv2.o unix.o -o squash1 -lc -lcrypt 
-static
$ file squash1
squash1: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux),
statically linked, for GNU/Linux 3.2.0, with debug_info, not stripped

hope this helps - and sorry for the delay in replying,

regards,
Gaius




reply via email to

[Prev in Thread] Current Thread [Next in Thread]