linux - 交叉编译GCC for linux i686-elf

标签 linux gcc cross-compiling glibc elf

我正在尝试从 Windows PC 交叉编译适用于 linux - i686-elf 平台的 gcc。根据工具链步骤,我已成功编译:

  1. 使用 binutils

    /binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror

  2. 基本的 gcc 使用

    gcc-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers

  3. 使用

    的 Linux header

    make headers_install ARCH=i386 CROSS_COMPILE=i386-linux- INDTALL_HDR_PATH=my/path/

现在,我正在尝试使用

编译“glibc”核心 C 库
`CC=${TARGET}-gcc ../glibc-2.29/configure --target=$TARGET --host=i686-pc-linux-gnu --prefix=$PREFIX --with-headers=my/path/`

但是我收到以下错误:(

/home/MyPC/src/glibc-2.29/elf/../sysdeps/unix/sysv/linux/not-cancel.h:57: undefined reference to `__GI___close_nocancel'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `invalid_name':
/home/MyPC/src/glibc-2.29/elf/../sysdeps/posix/opendir.c:43: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__fxstatat64':
/home/MyPC/src/glibc-2.29/elf/../sysdeps/unix/sysv/linux/fxstatat64.c:55: undefined reference to `__syscall_error'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/elf/../sysdeps/unix/sysv/linux/fxstatat64.c:37: undefined reference to `__syscall_error'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__closedir':
/home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/closedir.c:52: undefined reference to `__GI___close_nocancel'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/closedir.c:36: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__readdir':
/home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/readdir.c:41: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/readdir.c:76: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/readdir.c:71: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__rewinddir':
/home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/rewinddir.c:31: undefined reference to `__lseek'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__getdents':
/home/MyPC/src/glibc-2.29/dirent/../sysdeps/unix/sysv/linux/getdents.c:96: undefined reference to `__lseek64'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/dirent/../sysdeps/unix/sysv/linux/getdents.c:99: undefined reference to `__syscall_error'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/dirent/../sysdeps/unix/sysv/linux/getdents.c:54: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__fdopendir':
/home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/fdopendir.c:32: undefined reference to `__GI___fxstat64'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/fdopendir.c:41: undefined reference to `__GI___fcntl64_nocancel'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/fdopendir.c:36: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/dirent/../sysdeps/posix/fdopendir.c:46: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__libc_scratch_buffer_set_array_size':
/home/MyPC/src/glibc-2.29/malloc/scratch_buffer_set_array_size.c:41: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__mmap':
/home/MyPC/src/glibc-2.29/misc/../sysdeps/unix/sysv/linux/mmap.c:39: undefined reference to `__syscall_error'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/glibc-2.29/misc/../sysdeps/unix/sysv/linux/mmap.c:42: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `munmap':
/home/MyPC/src/glibc-2.29/misc/../sysdeps/unix/syscall-template.S:78: undefined reference to `__syscall_error'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__mprotect':
/home/MyPC/src/glibc-2.29/misc/../sysdeps/unix/syscall-template.S:78: undefined reference to `__syscall_error'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `uname':
/home/MyPC/src/glibc-2.29/posix/../sysdeps/unix/syscall-template.S:78: undefined reference to `__syscall_error'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__libc_sigaction':
/home/MyPC/src/glibc-2.29/signal/../sysdeps/unix/sysv/linux/sigaction.c:58: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `__sigaction':
/home/MyPC/src/glibc-2.29/signal/../nptl/sigaction.c:26: undefined reference to `rtld_errno'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/librtld.os: in function `setitimer':
/home/MyPC/src/glibc-2.29/time/../sysdeps/unix/syscall-template.S:78: undefined reference to `__syscall_error'
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: /home/MyPC/src/build-glibc/elf/ld.so.new: hidden symbol `__lseek64' isn't defined
/home/MyPC/opt/cross/lib/gcc/i686-elf/7.4.0/../../../../i686-elf/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:496: /home/MyPC/src/build-glibc/elf/ld.so] Error 1
make[2]: Leaving directory '/home/MyPC/src/glibc-2.29/elf'
make[1]: *** [Makefile:258: elf/subdir_lib] Error 2
make[1]: Leaving directory '/home/MyPC/src/glibc-2.29'
make: *** [Makefile:9: all] Error 2

最佳答案

这可能是由于 glibc can only be built on case-sensitive file systems 。您必须将托管构建树的文件系统切换为区分大小写的模式。

关于linux - 交叉编译GCC for linux i686-elf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54867682/

相关文章:

c++ - 命令行中缺少 DSO(使用 CMake)

linux - Bash编程快速搜索和提取方法

c++ - 使用 std::regex 匹配 BOL 和 EOL

c - 交叉编译时添加-O2选项导致展开回溯失败

android - Android 交叉编译时链接器错误

linux - 如何创建存档并对其进行 chmod

linux - 如何在 64 位 linux 中将静态库与 cmake 链接?

c - 在 CentOS 中 gcc 编译 c 程序时缺少包含文件

c++ - Visual Studio C++ 位域结构大小问题

c++ - 如何在 Eclipse CDT 中配置特定的 GCC 交叉工具链?