64位Slitaz Linux下Glibc 2.20編譯式更新安裝成功

一、編譯需求

我使用的是64位Slitaz的linux系統(中文),glibc的版本只有2.14.1,運行teamviewer時要求glibc 2.17,就開始了艱難的更新之路。
一開始,嘗試了將其他Linux系統帶的glibc庫文件複製入Slitaz 64,各種報錯。最後,我算是明白了,glibc不僅僅是libc.so.6 這一個文件,還有一堆文件。

二、編譯前的環境

在這裏插入圖片描述
這個64位,只是內核爲64位,能訪問4GB以上的內存,圖形界面和庫都是32位的。

三、編譯的程序包

在這裏插入圖片描述
要注意二點:
1、4.linux-api-headers,是slitaz系統相關的頭文件,如果其他的linux,包文件名可能會不同。
2、bash-5.0,如果不裝,不會在 configure命令時有報錯,但是編譯一半時,就會出現錯誤,導致編譯不能進行。這個經驗的價值非常高,一般都查不出來。

四、開始編譯

1、解壓glicb-2.20.tar.bz2壓縮包,進入解壓後的目錄。
2、mkdir build
3、cd build
4、最關鍵的配置命令,生成32位的glibc庫

../configure  --prefix=/usr  --build=i686-linux --host=i686-linux

下面是打好命令後的輸出

checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking for readelf... readelf
checking for sysdeps preconfigure fragments... aarch64 alpha arm hppa i386 m68k microblaze mips powerpc s390 sh sparc tile x86_64 
configure: running configure fragment for add-on libidn
checking for assembler and linker STT_GNU_IFUNC support... yes
checking whether .text pseudo-op must be used... yes
checking sysdep dirs... sysdeps/unix/sysv/linux/i386/i686 sysdeps/i386/i686/nptl sysdeps/unix/sysv/linux/i386 sysdeps/unix/sysv/linux/x86 sysdeps/i386/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/i386 sysdeps/unix sysdeps/posix sysdeps/i386/i686/fpu/multiarch sysdeps/i386/i686/fpu sysdeps/i386/i686/multiarch sysdeps/i386/i686 sysdeps/i386/i486 sysdeps/i386/fpu sysdeps/x86/fpu sysdeps/i386 sysdeps/x86 sysdeps/wordsize-32 sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/ieee754 sysdeps/generic
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking whether as is GNU as... yes
checking whether ld is GNU ld... yes
checking for as... as
checking version of as... 2.33.1, ok
checking for ld... ld
checking version of ld... 2.33.1, ok
checking for gcc... gcc
checking version of gcc... 4.6.3, ok
checking for gnumake... no
checking for gmake... no
checking for make... make
checking version of make... 4.3, ok
checking for gnumsgfmt... no
checking for gmsgfmt... no
checking for msgfmt... no
checking for makeinfo... no
checking for sed... sed
checking version of sed... 4.0, ok
checking for gawk... gawk
checking version of gawk... 5.0.1, ok
checking for nm... nm
configure: WARNING:
*** These auxiliary programs are missing or incompatible versions: msgfmt makeinfo
*** some features will be disabled.
*** Check the INSTALL file for required versions.
checking LD_LIBRARY_PATH variable... ok
checking whether GCC supports -static-libgcc... -static-libgcc
checking for bash... /bin/bash
checking for perl... no
checking for install-info... no
checking for bison... /usr/bin/bison
checking for libc-friendly stddef.h... yes
checking whether we need to use -P to assemble .S files... no
checking for .set assembler directive... yes
checking for assembler gnu_unique_object symbol type... yes
checking for .previous assembler directive... yes
checking for .protected and .hidden assembler directive... yes
checking whether __attribute__((visibility())) is supported... yes
checking for broken __attribute__((visibility()))... no
checking for broken __attribute__((alias()))... no
checking whether to put _rtld_local into .sdata section... no
checking for .preinit_array/.init_array/.fini_array support... yes
checking whether to use .ctors/.dtors header and trailer... yes
checking for libunwind-support in compiler... no
checking for linker that supports -z nodelete... yes
checking for linker that supports -z nodlopen... yes
checking for linker that supports -z initfirst... yes
checking for -Bgroup option... yes
checking whether --noexecstack is desirable for .S files... yes
checking for -z combreloc... yes
checking for linker that supports -z execstack... yes
checking for -fpie... yes
checking for --hash-style option... yes
checking for sufficient default -shared layout... no
checking linker output format... elf32-i386
checking for -fno-toplevel-reorder -fno-section-anchors... yes
checking for -fstack-protector... yes
checking for -fgnu89-inline... yes
checking whether cc puts quotes around section names... no
checking for assembler .weak directive... yes
checking for ld --no-whole-archive... yes
checking for gcc -fexceptions... yes
checking for __builtin_memset... yes
checking for redirection of built-in functions... yes
checking for __thread... yes
checking for tls_model attribute... yes
checking for compiler option to disable generation of FMA instructions... -ffp-contract=off
checking if gcc accepts -fno-tree-loop-distribute-patterns with __attribute__ ((__optimize__))... yes
checking for libgd... no
checking for is_selinux_enabled in -lselinux... no
checking size of long double... 12
checking for _FORTIFY_SOURCE predefine... no
checking whether gcc implicitly enables -fstack-protector... no
checking whether the linker provides working __ehdr_start... yes
checking for __builtin_trap with no external dependencies... yes
running configure fragment for sysdeps/unix/sysv/linux/i386
running configure fragment for sysdeps/unix/sysv/linux
checking installed Linux kernel header files... 2.6.32 or later
checking for kernel header at least 2.6.32... ok
checking for linux/fanotify.h... yes
checking for symlinks in /opt/glibc.20/include... ok
running configure fragment for sysdeps/nptl
checking for forced unwind support... yes
checking for C cleanup handling... yes
running configure fragment for sysdeps/gnu
running configure fragment for sysdeps/i386
checking for compiler support of inlined builtin function __sync_val_compare_and_swap... yes
checking for cpuid.h... yes
checking for SSE4 support... yes
checking for assembler -mtune=i686 support... yes
checking for AVX support... yes
checking for AVX encoding of SSE instructions... yes
checking for FMA4 support... yes
checking for -mno-vzeroupper support... yes
checking for AVX2 support... yes
checking for old glibc 2.0.x headers... no
checking whether -fPIC is default... no
configure: creating ./config.status
config.status: creating config.make
config.status: creating Makefile
config.status: creating config.h
config.status: executing default commands

生成的config.make,可以檢查一下,有幾行比較關鍵:

# Installation prefixes.
prefix = /usr
slibdir = /lib
rtlddir = /lib
# System configuration.
config-machine = i686  #32位
base-machine = i386    #32位
config-vendor = pc
config-os = linux-gnu

output-format = elf32-i386  #32位

我的理解,上面的/lib就說明會安裝到/lib目錄下,只要你打了 make install

5、編譯

make

我的筆記本是ATOM N450, 2GB MEM,花了52分鐘,爲了證明make結果沒有出錯,見下圖:
在這裏插入圖片描述
6、安裝,如上所述,不僅僅是一個libc.so文件,需要安裝許多文件。

make install

會安裝到 /lib目錄,可以去檢查下新的libc.so.6指向哪個版本的glibc庫

ls -l /lib/libc.so.6

如果顯示指向了libc-2.20.so,那就成功了。

root@slitaz:/home/tux/Downloads/glibc-2.20/build] ls -l /lib/libc.so.6
lrwxrwxrwx    1 root     root            12 May 16 12:50 /lib/libc.so.6 -> libc-2.20.so

五、總結

經過了至少一週的折騰,configure報了不少的錯,即使編譯都沒錯了,因爲–prefix目錄設置得太保守,make install後,建軟連接至/lib/libc.so.6 或用 export LD-LIBRARY_PATH都是以失敗告終的。還好最後沒放棄,查了CSDN幾十篇文章後,最終還是成功了。
我看到有的文章說,真正編譯更新成功的人沒幾個,現在你看了這篇文章後,成功的可能性將是很大(如果成功或失敗,都歡迎你在下面評論留言)。大不了,重新安裝初始系統後再開始glibc的編譯之旅。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章