在 Alpine 上构建 glibc 时出错 Linux
Errors when building glibc on Alpine Linux
我正在尝试在 Alpine Linux 上安装 glibc
。我是 运行ning Alpine Linux 中的 Docker。以下是我使用的步骤:
docker pull alpine
docker run -it alpine /bin/sh
apk add --no-cache make gcc linux-headers bsd-compat-headers gawk bison binutils coreutils diffutils gettext bash grep sed texinfo perl
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
tar -xzf glibc-2.28.tar.gz
cd glibc-2.28
mkdir glibc-build
cd glibc-build
../configure --prefix=/usr \
--disable-profile --enable-add-ons \
--libexecdir=/usr/bin --with-headers=/usr/include \
--enable-static-pie
cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
# End /etc/ld.so.conf
EOF
make
make install
我在第 11 步遇到以下错误:
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:129: /glibc-2.28/glibc-build/elf/sotruss-lib.so] Error 1
make[2]: Leaving directory '/glibc-2.28/elf'
make[1]: *** [Makefile:258: elf/subdir_lib] Error 2
make[1]: Leaving directory '/glibc-2.28'
make: *** [Makefile:9: all] Error 2
如果我尝试添加 --disable-shared
标志,则会发生另一个错误。
可以通过使用以下命令添加 libc-dev
来解决错误:apk add --no-cache libc-dev
。但是这样我会有两个 C 库,但我需要我的应用程序专门使用 glibc
。
更新
如果我 运行 apk add --no-cache libc-dev
,make
命令成功通过但 make install
失败并出现以下错误:
Execution of gcc failed!
The script has found some problems with your installation!
Please read the FAQ and the README file and check the following:
Did you change the gcc specs file (necessary after upgrading from
Linux libc5)?
Are there any symbolic links of the form libXXX.so to old libraries?
Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,
libm.so should point to the newly installed glibc file - and there should be
only one such link (check e.g. /lib and /usr/lib)
You should restart this script from your build directory after you've
fixed all problems!
Btw. the script doesn't work if you're installing GNU libc not as your
primary library!
安装 musl-dev
应该也能让您克服构建错误,因此您将针对 musl 构建 glibc。
musl-dev
包有自己的 /usr/lib/libssp_nonshared.a
:
最后,为了在 Alpine Linux.
上构建 glibc
,我更改了几个步骤
以下是对我有用的步骤:
docker pull alpine
docker run -it alpine /bin/sh
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
tar -xzf glibc-2.28.tar.gz
cd glibc-2.28
mkdir glibc-build
cd glibc-build
apk add --no-cache make gcc gawk bison linux-headers libc-dev
../configure --prefix=/usr \
--disable-profile --enable-add-ons \
--libexecdir=/usr/lib --with-headers=/usr/include \
--without-cvs --enable-static-pie
cat > /etc/ld.so.conf << "EOF" # Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
/usr/lib
/usr/lib64
/usr/libexec
# End /etc/ld.so.conf
EOF
make
make install
我希望这些步骤也适用于其他人。
我正在尝试在 Alpine Linux 上安装 glibc
。我是 运行ning Alpine Linux 中的 Docker。以下是我使用的步骤:
docker pull alpine
docker run -it alpine /bin/sh
apk add --no-cache make gcc linux-headers bsd-compat-headers gawk bison binutils coreutils diffutils gettext bash grep sed texinfo perl
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
tar -xzf glibc-2.28.tar.gz
cd glibc-2.28
mkdir glibc-build
cd glibc-build
../configure --prefix=/usr \ --disable-profile --enable-add-ons \ --libexecdir=/usr/bin --with-headers=/usr/include \ --enable-static-pie
cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf /usr/local/lib /opt/lib # End /etc/ld.so.conf EOF
make
make install
我在第 11 步遇到以下错误:
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:129: /glibc-2.28/glibc-build/elf/sotruss-lib.so] Error 1
make[2]: Leaving directory '/glibc-2.28/elf'
make[1]: *** [Makefile:258: elf/subdir_lib] Error 2
make[1]: Leaving directory '/glibc-2.28'
make: *** [Makefile:9: all] Error 2
如果我尝试添加 --disable-shared
标志,则会发生另一个错误。
可以通过使用以下命令添加 libc-dev
来解决错误:apk add --no-cache libc-dev
。但是这样我会有两个 C 库,但我需要我的应用程序专门使用 glibc
。
更新
如果我 运行 apk add --no-cache libc-dev
,make
命令成功通过但 make install
失败并出现以下错误:
Execution of gcc failed!
The script has found some problems with your installation!
Please read the FAQ and the README file and check the following:
Did you change the gcc specs file (necessary after upgrading from Linux libc5)?
Are there any symbolic links of the form libXXX.so to old libraries?
Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,
libm.so should point to the newly installed glibc file - and there should be
only one such link (check e.g. /lib and /usr/lib)
You should restart this script from your build directory after you've fixed all problems!
Btw. the script doesn't work if you're installing GNU libc not as your primary library!
安装 musl-dev
应该也能让您克服构建错误,因此您将针对 musl 构建 glibc。
musl-dev
包有自己的 /usr/lib/libssp_nonshared.a
:
最后,为了在 Alpine Linux.
上构建glibc
,我更改了几个步骤
以下是对我有用的步骤:
docker pull alpine
docker run -it alpine /bin/sh
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
tar -xzf glibc-2.28.tar.gz
cd glibc-2.28
mkdir glibc-build
cd glibc-build
apk add --no-cache make gcc gawk bison linux-headers libc-dev
../configure --prefix=/usr \ --disable-profile --enable-add-ons \ --libexecdir=/usr/lib --with-headers=/usr/include \ --without-cvs --enable-static-pie
cat > /etc/ld.so.conf << "EOF" # Begin /etc/ld.so.conf /usr/local/lib /opt/lib /usr/lib /usr/lib64 /usr/libexec # End /etc/ld.so.conf EOF
make
make install
我希望这些步骤也适用于其他人。