How to set sysroot for cross compiling?

Kai Ruottu
Thu Aug 10 11:15:01 GMT 2023

unlvsur unlvsur kirjoitti 6.8.2023 klo 23.35:
> x86_64-ubuntu-linux-gnu-g++ -v
> Using built-in specs.
> COLLECT_GCC=x86_64-ubuntu-linux-gnu-g++
> COLLECT_LTO_WRAPPER=/home/cqwrteur/toolchains/x86_64-pc-linux-gnu/x86_64-ubuntu-linux-gnu/libexec/gcc/x86_64-ubuntu-linux-gnu/14.0.0/lto-wrapper
> Target: x86_64-ubuntu-linux-gnu
> <snip>
> gcc version 14.0.0 20230802 (experimental) (GCC)
> Arsen Arsenović via Gcc-help kirjoitti 3.8.2023 klo 13.06:
> > unlvsur unlvsur <> writes:
> >
> >> i do set with multilib list, the problem is that gcc gets very 
> messed up when
> >> trying to find where the libs located at build.
> >>
> >> like only trying to find lib64 in $targettriple/$targettriple/lib, 
> lib32 in
> >> $targettriple/$targettriple/lib/32, libx32 in
> >> $targettriple/$targettriple/lib/x32
> >>
> >> It won't find anywhere else for libc
> > Please post more information.  This could, perhaps, be binutils
> > misconfiguration.
> Sounds sane if one forgot to use the '--with-sysroot=' when configuring
> the GNU binutils for
> the target system. Here seemingly 'x86_64-linux-androideabi' when
> mentioning these three multilib directories.
So the target was Ubuntu...
Last when I tried this target there weren't the 'x32' libraries, only 
the 32- and 64-bit ones.
So maybe it was the time to try a newer Ubuntu target. The "22.04.2" 
seemed to be suitable
to try.
As you told, the target headers and libraries seemed to be a big mess 
when looking in which
packages they were delivered. The "Desktop" release ISO-package seemed 
to provide only a
subset and one needed to look at the "pool/main" archives. The Ubuntu 
mirror in Finland had
even this somehow "stripped" because I got this error when trying 
gcc-11.4.0 for
the 'x86_64-ubuntu-linux22.04' target :

-B/opt/cross/x86_64-ubuntu-linux22.04/lib/ -isystem 
/opt/cross/x86_64-ubuntu-linux22.04/include -isystem 
/opt/cross/x86_64-ubuntu-linux22.04/sys-include    -g -O2 -mx32 -O2 -g 
-Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes 
-Wold-style-definition  -isystem ./include -fpic -mlong-double-80 
-DUSE_ELF_SYMVER -fcf-protection -mshstk -g -DIN_LIBGCC2 
-fbuilding-libgcc -fno-stack-protector  -fpic -mlong-double-80 
-DUSE_ELF_SYMVER -fcf-protection -mshstk -I. -I. -I../../.././gcc 
-I../../../../libgcc -I../../../../libgcc/. -I../../../../libgcc/../gcc 
-I../../../../libgcc/../include -I../../../../libgcc/config/libbid 
_muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c 
../../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from 
                  from ../../../../libgcc/../gcc/tsystem.h:93,
                  from ../../../../libgcc/libgcc2.c:27:
/opt/host-x86_64-ubuntu-linux22.04/usr/include/linux/errno.h:1:10: fatal 
error: asm/errno.h: No such file or directory
     1 | #include <asm/errno.h>
       |          ^~~~~~~~~~~~~
compilation terminated.

The 'kernel headers' were from the two 
'linux-libc-dev_5.15.0-78.85_*.deb' packages but something
was missing for the '-mx32' case. Earlier there were a faulty symlink to 
'/lib/' or what the
32-bit one is. Of course this shouldn't be to the absolute '/lib' but to 
the relative '../lib'. And all the
32-bit headers were missing, the desktop-image providing only a 
package for which the 'linux-libc-dev_5.15.0-60.66_i386.deb' equivalent 
wasn't found. Therefore using
the '78.85' packages. Let's see whether the found 
has all the required headers...

More information about the Gcc-help mailing list