Buildroot 编译错误,librt.so:未定义的引用

Buildroot 编译错误,librt.so:未定义的引用

我正在尝试编译一个构建根使用预配置的内置 _defconfig 文件的图像...更具体地说 riscv64_xwin_defconfig 这是内置 Xorg 的 riscv64 图像的简单设置。

由于这是一个相当旧的构建,我在具有 gcc 版本 5.3.1 的 Fedora 23 Docker 容器中执行此操作,我认为这不是问题,因为我可以成功构建非 Xwin riscv64 defconfig 就好

当 Makefile 尝试构建特定包“eudev-3.2”时出现问题

这是配置日志:

configure:3158: $? = 1
configure:3178: checking whether the C compiler works
configure:3200: /home/buildroot-riscv-2018-10-20/output/host/usr/bin/riscv64-buildroot-linux-gnu-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  conftest.c -lrt >&5
/home/buildroot-riscv-2018-10-20/output/host/usr/lib/gcc/riscv64-buildroot-linux-gnu/7.3.0/../../../../riscv64-buildroot-linux-gnu/bin/ld: warning: libpthread.so.0, needed by /home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so, not found (try using -rpath or -rpath-link)
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__pthread_barrier_wait@GLIBC_PRIVATE'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_attr_setstacksize@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__pthread_barrier_init@GLIBC_PRIVATE'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__pthread_unwind@GLIBC_PRIVATE'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_create@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_sigmask@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_once@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__shm_directory@GLIBC_PRIVATE'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_detach@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_cancel@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__pthread_get_minstack@GLIBC_PRIVATE'
collect2: error: ld returned 1 exit status

答案1

看起来有人忘记显式链接 libpthread。-lpthread在最后添加(在 后面-lrt)应该可以解决当前的问题。查看您的 Makefile 以找出需要在何处添加-lpthread.

相关内容