编译安装glibc



首先从gnu官网下载最新版的glibc,地址http://www.gnu.org/software/libc/ 

编译步骤:

下载glibc-2.15.tar.gz和补丁包glibc-ports-2.15.tar.gz

解压

$mv glibc-ports-2.15 glibc-2.15/ports

$mkdir glibc-build-2.15 &&cd glibc-build-2.15

$ ../glibc-2.15/configure \
    --prefix=/usr/local/glibc_mips \
    CC=mipsel-linux-gcc \
    --host=mipsel-linux \
    --build=i686-pc-linux-gnu \
    --enable-add-on=nptl \
    libc_cv_forced_unwind=yes \  
    libc_cv_c_cleanup=yes \
    libc_cv_mips_tls=yes \
    libc_cv_gnu99_inline=yes 
ok,没问题

$make &&make install

大功告成


##########################################################################

下面是我编译时的过程和遇到的问题及解决:

##########################################################################


$tar xvf glibc-2.16.0.tar.bz2

$cd glibc-2.16.0

$./configure --prefix=/usr/local/glibc   //先不加其他选项,除了安装路径,一切默认,网上一般配置arm的选项如下 --prefix=$HOME/usr/arm --with-headers=$HOME/usr/arm/glibc/arm-linux-glibc/include --with-libs=$HOME/usr/arm/glibc/arm-linux-glibc/lib 

报错:

configure: error: you must configure in a separate build directory

很奇怪的问题,必须配置一个构建目录,刚开始以为是安装目录为创建

$mkdir /usr/local/glibc

问题仍然存在,百度之

$mkdir ../glibc-build && cd ../glibc-build

$../glibc-2.16.0/configure --prefix=/usr/local/glibc

出现新的问题:

configure: WARNING:

*** These auxiliary programs are missing or incompatible versions: msgfmt

*** some features will be disabled.

*** Check the INSTALL file for required versions.

checking LD_LIBRARY_PATH variable... contains current directory

configure: error:

*** LD_LIBRARY_PATH shouldn't contain the current directory when

*** building glibc. Please change the environment variable

*** and run configure again.

第一个警告不用管它,第二个LD_LIBRARY_PATY也会有错?我的这个路径用了多少天了。仔细看提示,不应包含当前路径。打开~/.bash_profile
$cat ~/.bash_profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH
这也没当前路径啊。还是百度吧。
一个兄弟的解释是这样“LD_LIBRARY_PATH不能以终结符作为开始和最后一个字符,不能有2个终结符连在一起,我的LD_LIBRARY_PATH为 :/usr/local/firefox:/usr/local/firefox,只要在前面加上一个路径,不让:出现在第一个字符就可以了 ”
原来如此,第一个字符不能是":",修改~/.bash_profile
export LD_LIBRARY_PATH=/usr/local/lib export LD_LIBRARY_PATH 
$../glibc-2.16.0/configure --prefix=/usr/local/glibc
ls一下,发现,当前目录生成了Makefile等一堆东西
$make && make install
没问题

下一步开始交叉编译
$mkdir ../glibc-build-mips && cd ../glibc-build-mips
$ ../glibc-2.16.0/configure --prefix=/usr/local/glibc_mips CC=mipsel-linux-gcc --host=mips
出现新的问题:
configure: running configure fragment for add-on libidn
configure: running configure fragment for add-on nptl
*** The GNU C library is currently not available for this platform.
*** So far nobody cared to port it and if there is no volunteer it
*** might never happen.  So, if you have interest to see glibc on
*** this platform visit
***     http://www.gnu.org/software/libc/porting.html
*** and join the group of porters
看起来像是需要path,下载glibc-ports-2.16.tar.gz,放在源码包目录,解压

$ ../glibc-2.16.0/configure \
    --prefix=/usr/local/glibc_mips \
    CC=mipsel-linux-gcc \
    CXX=mipsel-linux-g++ \
    --host=mips \
    --enable-add-ons=/home/hb/code/glibc/glibc-ports-2.16.0/sysdeps/mips

仍然报错:

configure: error: fragment must set $libc_add_on_canonical

改为:

$ ../glibc-2.16.0/configure \
    --prefix=/usr/local/glibc_mips \
    CC=mipsel-linux-gcc \
    CXX=mipsel-linux-g++ \
    --host=mips \
    --enable-add-ons

报错:

configure: error: The mipsel is not supported.

这样不行,谷歌半天,总算知道补丁怎么用的了。把补丁目录拷到glibc目录下,改名为ports

$mv glibc-ports-2.16.0/ glibc-2.16.0/ports

$../glibc-2.16.0/configure \
    --prefix=/usr/local/glibc_mips \
    CC=mipsel-linux-gcc \
    CXX=mipsel-linux-g++ \
    --host=mipsel-linux \
    --build=i686-pc-linux-gnu \
    --enable-add-on

继续报错:

configure: error: 
*** These critical programs are missing or too old: ld as
*** Check the INSTALL file for required versions.
这个问题可折腾死我了。弄了好半天,就是不行,最后google发现,原来是ld和as版本不对,不是太高就是太低。

configure中找到$AS --version

发现版本是这么匹配的2.1*.*

$mipsel-linux-ld

GNU ld (GNU Binutils) 2.18.50.20080908
原来是这样,在configure版本号那一行修改,最后的括号前面加入

|2.18.50.×

as那一行也同样修改

然后

$make

开始编译,看起来不错

好半天后,编译也报错了

In file included from ../include/uchar.h:1,
                 from mbrtoc16.c:23:
../wcsmbs/uchar.h:47:5: error: #error "<uchar.h> requires ISO C11 mode"
In file included from ../include/uchar.h:1,
                 from mbrtoc16.c:23:
../wcsmbs/uchar.h:52: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char16_t'
../wcsmbs/uchar.h:53: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char32_t'
../wcsmbs/uchar.h:61: error: expected ')' before '*' token
../wcsmbs/uchar.h:66: error: expected declaration specifiers or '...' before 'char16_t'
../wcsmbs/uchar.h:73: error: expected ')' before '*' token
../wcsmbs/uchar.h:78: error: expected declaration specifiers or '...' before 'char32_t'
mbrtoc16.c:37: error: expected ')' before '*' token
make[2]: *** [/home/hb/code/glibc/glibc-build-mips/wcsmbs/mbrtoc16.o] 错误 1
make[2]:正在离开目录 `/home/hb/code/glibc/glibc-2.16.0/wcsmbs'
make[1]: *** [wcsmbs/subdir_lib] 错误 2
make[1]:正在离开目录 `/home/hb/code/glibc/glibc-2.16.0'
make: *** [all] 错误 2
看看这个头文件咋回事

$ vim ../glibc-2.16.0/wcsmbs/uchar.h

#if defined __GNUC__ && !defined __USE_ISOCXX11
/* Define the 16-bit and 32-bit character types.  Use the information
   provided by the compiler.  */
# if !defined __CHAR16_TYPE__ || !defined __CHAR32_TYPE__
#  if defined __STDC_VERSION__ && __STDC_VERSION__ < 201000L
#   error "<uchar.h> requires ISO C11 mode"
#  else
#   error "definitions of __CHAR16_TYPE__ and/or __CHAR32_TYPE__ missing"
#  endif

# endif


明白了,原来是需要c11支持,mipsel-linux-gcc -v一下,我的支持c99.原来如此。暂时没招了,我还做不到修改c11的支持,只剩两个办法,不用这个glibc版本或者重新编译一个支持c11的交叉编译器。编译器需要做的比较多,暂时先换个低点的版本吧。

下载galibc-2.15版本

重复上面步骤,解压tar包

解压ports包

$mv glibc-ports-2.15 glibc-2.15/ports

$mkdir glibc-build-2.15 &&cd glibc-build-2.15

$ ../glibc-2.15/configure \
    --prefix=/usr/local/glibc_mips \
    CC=mipsel-linux-gcc \
    --host=mipsel-linux \
    --build=i686-pc-linux-gnu \
    --enable-add-on=nptl \
    libc_cv_forced_unwind=yes \  
    libc_cv_c_cleanup=yes \
    libc_cv_mips_tls=yes \
    libc_cv_gnu99_inline=yes 
ok,没问题

$make &&make install

库已经编好了,但是不能直接使用,必须再用新的库重编一遍编译器才行。

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值