centos 6.7 安装dotnet 6.0.201
.net core 官网地址
https://dotnet.microsoft.com/download
本次安装版本为.net 6 SDK v6.0.201
1、查看系统版本, 升级系统基本lib库
[root@test ~]# cat /etc/redhat-release CentOS release 6.7 (Final)
[root@test ~]# yum update //可以执行此步骤,减少后面lib库依赖的痛苦。
2、下载.net core SDK v6.0.3 安装文件,并解压到指定目录
[root@test ~]#wget https://download.visualstudio.microsoft.com/download/pr/c505a449-9ecf-4352-8629-56216f521616/bd6807340faae05b61de340c8bf161e8/dotnet-sdk-6.0.201-linux-x64.tar.gz -P /usr/local/src [root@test ~]#cd /usr/local/src [root@test src]#mkdir -p /usr/local/dotnetcore [root@test src]#tar -zxf dotnet-sdk-6.0.201-linux-x64.tar.gz -C /usr/local/dotnetcore
3、添加net core环境变量
[root@test src]# vi /etc/profile 增加以下几行 #set dotnet core export DOTNET_ROOT=/usr/local/dotnetcore export PATH=$PATH:$DOTNET_ROOT
#生效环境变量
[root@test src]#source /etc/profile
4、查看dotnet 版本
[root@test src]# dotnet --version dotnet: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by dotnet) dotnet: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.17' not found (required by dotnet) dotnet: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by dotnet) dotnet: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by dotnet) dotnet: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by dotnet)
5、OMG,报错了。接下来才是重点,一步步解决到错误,首先查看GCC版本和默认动态库
5.1查看默认的gcc版本
[root@test src]# gcc --version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23) Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5.2查看默认动态库
[root@test src]# strings /usr/lib64/libstdc++.so.6 | grep GLIBC GLIBCXX_3.4 GLIBCXX_3.4.1 GLIBCXX_3.4.2 GLIBCXX_3.4.3 GLIBCXX_3.4.4 GLIBCXX_3.4.5 GLIBCXX_3.4.6 GLIBCXX_3.4.7 GLIBCXX_3.4.8 GLIBCXX_3.4.9 GLIBCXX_3.4.10 GLIBCXX_3.4.11 GLIBCXX_3.4.12 GLIBCXX_3.4.13 GLIBC_2.2.5 GLIBC_2.3 GLIBC_2.4 GLIBC_2.3.2 GLIBCXX_FORCE_NEW GLIBCXX_DEBUG_MESSAGE_LENGTH
##低版本的gcc 不支持C++11的特性没有 GLIBCXX_3.4.14\GLIBCXX_3.4.15\GLIBCXX_3.4.17\GLIBCXX_3.4.18
此时有两种解决办法,首先,从其他地方拷贝一个libstdc++.so.6.0.19版本 ,或者其他高版本
上传文件到/usr/lib64 目录下
ln -sf libstdc++.so.6.0.19 libstdc++.so.6
此时在查看
[root@test src]# strings /usr/lib64/libstdc++.so.6 | grep GLIBC
已经支持C++11 特性了。
自己编译gcc,下面步骤是编译gcc 4.8.5
5.3因为在centos 7 安装直接安装官方文档即可,默认centos7 gcc版本是4.8.5 ,所以在此也选择升级到版本为4.8.5
GCC官网链接:https://gcc.gnu.org/
5.3.1下载gcc 4.8.5 安装包并解压
[root@test src]# wget http://mirror.linux-ia64.org/gnu/gcc/releases/gcc-4.8.5/gcc-4.8.5.tar.gz [root@test src]# tar -zxf gcc-4.8.5.tar.gz
5.3.2 检查链接gcc升级依赖包mpfr-2.4.2、gmp-4.3.2、mpc-0.8.1
[root@test src]# cat gcc-4.8.5/contrib/download_prerequisites #! /bin/sh # Download some prerequisites needed by gcc. # Run this from the top level of the gcc source tree and the gcc # build will do the right thing. # # (C) 2010 Free Software Foundation # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. MPFR=mpfr-2.4.2 GMP=gmp-4.3.2 MPC=mpc-0.8.1 wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPFR.tar.bz2 || exit 1 tar xjf $MPFR.tar.bz2 || exit 1 ln -sf $MPFR mpfr || exit 1 wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$GMP.tar.bz2 || exit 1 tar xjf $GMP.tar.bz2 || exit 1 ln -sf $GMP gmp || exit 1 wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPC.tar.gz || exit 1 tar xzf $MPC.tar.gz || exit 1 ln -sf $MPC mpc || exit 1 rm $MPFR.tar.bz2 $GMP.tar.bz2 $MPC.tar.gz || exit 1
5.3.3 按照脚本指示下载、解压、链接
[root@test src]# wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2 [root@test src]# wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2 [root@test src]# wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
查看下载的文件
[root@test src]# ls *tar.* gmp-4.3.2.tar.bz2 mpc-0.8.1.tar.gz mpfr-2.4.2.tar.bz2 [root@test src]# tar xjf mpfr-2.4.2.tar.bz2 [root@test src]# tar xjf gmp-4.3.2.tar.bz2 [root@test src]# tar -xzf mpc-0.8.1.tar.gz [root@test src]# ln -sf mpfr-2.4.2 gcc-4.8.5/mpfr [root@test src]# ln -sf gmp-4.3.2 gcc-4.8.5/gmp [root@test src]# ln -sf mpc-0.8.1 gcc-4.8.5/mpc
5.3.4生成编译文件
[root@test src]# cd gcc-4.8.5 [root@test gcc-4.8.5]# ./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
##如果没有报错,接着执行make ,如果多核心可以make -j4 ,过程比较长,可以看个小黄片,泡个咖啡等上半个小时。
[root@test gcc-4.8.5]# make -j4
[root@test gcc-4.8.5]# make install
5.3.5安装完GCC,检查一下
##此时证明安装gcc成功
[root@test src]# cp /usr/local/lib64/libstdc++.so.6.0.19 /usr/lib64/
[root@test src]# cd /usr/lib64/
[root@test lib64]# rm -f libstdc++.so.6
[root@test lib64]# ln -s libstdc++.so.6.0.19 libstdc++.so.6
5.3.6 再次检查dotnet core 版本
[root@test gcc-4.8.5]# dotnet --version Failed to load error: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/local/dotnetcore/host/fxr/2.2.0/libhostfxr.so) The library libhostfxr.so was found, but loading it from /usr/local/dotnetcore/host/fxr/2.2.0/libhostfxr.so failed - Installing .NET Core prerequisites might help resolve this problem. http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409 ###又提示报错,需要GLIBC_2.14支持
6.查看系统glibc支持的版本
[root@test src]# strings /lib64/libc.so.6 |grep GLIBC_ GLIBC_2.2.5 GLIBC_2.2.6 GLIBC_2.3 GLIBC_2.3.2 GLIBC_2.3.3 GLIBC_2.3.4 GLIBC_2.4 GLIBC_2.5 GLIBC_2.6 GLIBC_2.7 GLIBC_2.8 GLIBC_2.9 GLIBC_2.10 GLIBC_2.11 GLIBC_2.12 GLIBC_PRIVATE ##可以看到最高的版本是GLIBC_2.12,没有GLIBC_2.14。我们在此解决一下
6.1 下载glibc
[root@test src]# cd /usr/local/lib [root@test lib]# wget -c http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz [root@test lib]# tar -zxf glibc-2.14.tar.gz [root@test lib]# cd glibc-2.14
6.2 在glibc源码目录建立构建目录,并make 安装
[root@test glibc-2.14]# mkdir build && cd build [root@test build]# ../configure --prefix=/opt/glibc-2.14 [root@test build]# make j4
[root@test build]# make j4 localedata/install-locales //如果不执行这一步,直接就导致了后面locale的设置问题
[root@test build]# make j4 install
6.3配置
[root@test glibc-2.14]cp /etc/ld.so.c* /opt/glibc-2.14/etc/ [root@test glibc-2.14]ln -sf /opt/glibc-2.14/lib/libc-2.14.so /lib64/libc.so.6
注意
删除libc.so.6
之后可能导致系统命令不可用的情况, 可使用如下方法解决:
如果上述更新失败可使用如下命令还原:
6.4查看版本库支持
[root@test build]# strings /lib64/libc.so.6 |grep GLIBC_ GLIBC_2.2.5 GLIBC_2.2.6 GLIBC_2.3 GLIBC_2.3.2 GLIBC_2.3.3 GLIBC_2.3.4 GLIBC_2.4 GLIBC_2.5 GLIBC_2.6 GLIBC_2.7 GLIBC_2.8 GLIBC_2.9 GLIBC_2.10 GLIBC_2.11 GLIBC_2.12 GLIBC_2.13 GLIBC_2.14 GLIBC_PRIVATE ##已经支持 GLIBC_2.14
6.5 再次检查dotnet core 版本
[root@test build]# dotnet --version FailFast: Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. at System.Environment.FailFast(System.String) at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode() at System.Globalization.GlobalizationMode..cctor() at System.Globalization.CultureData.CreateCultureWithInvariantData() at System.Globalization.CultureData.get_Invariant() at System.Globalization.CultureInfo..cctor() at System.StringComparer..cctor() at System.AppDomain.InitializeCompatibilityFlags() at System.AppDomain.Setup(System.Object) Aborted (core dumped) ###又提示缺少ICU,真是一波三折啊
7.安装ICU,使用源码的方式安装icu. 我选择的是59.1版本,安装59.1可能有报错信息,如下:
make[1]: *** [stubdata.o] Error 1
make[1]: Leaving directory `/root/icu/source/stubdata'
make: *** [all-recursive] Error 2
换成56.1版本可以解决 下载地址http://download.icu-project.org/files/icu4c/56.1/icu4c-56_1-src.tgz
[root@test build]# cd /usr/local/src/
[root@test src]# wget https://github.com/unicode-org/icu/releases/download/release-56-1/icu4c-56_1-src.tgz
[root@test src]# tar -xzvf icu4c-56_1-src.tgz
[root@test src]# cd icu/source
[root@test source]# ./configure --prefix=/usr/local/icu
[root@test source]# gmake && make install
安装过程一样,软链接创建时候请注意不要直接copy
但是本次使用59.1安装
[root@test build]# cd /usr/local/src/ [root@test src]# wget http://download.icu-project.org/files/icu4c/59.1/icu4c-59_1-src.tgz [root@test src]# tar -xzvf icu4c-59_1-src.tgz [root@test src]# cd icu/source [root@test source]# ./configure --prefix=/usr/local/icu [root@test source]# gmake && make install 参看是否安装成功: [root@test source]# cd /usr/local/icu/bin [root@test bin]# ./icu-config --version 59.1 [root@test bin]# ./icuinfo ./icuinfo: error while loading shared libraries: libicutu.so.59: cannot open shared object file: No such file or directory 但是查看具体信息会提示缺少 libicutu.so.59,其他缺少的dll,同样处理。 [root@test bin]# find / -name libicutu.so.59 /lib64/libicutu.so.59 /usr/local/icu/lib/libicutu.so.59 /usr/local/src/icu/source/lib/libicutu.so.59 [root@test bin]# ln -s /usr/local/icu/lib/libicutu.so.59 /lib64/ [root@test bin]# ln -s /usr/local/icu/lib/libicui18n.so /lib64/ [root@test bin]# ln -s /usr/local/icu/lib/libicuuc.so.59 /lib64/ [root@test bin]# ln -s /usr/local/icu/lib/libicudata.so.59 /lib64/
[root@test bin]# ln -s /usr/local/icu/lib/libicui18n.so /lib64/libicui18n.so.59
[root@test bin]# ldd icuinfo linux-vdso.so.1 => (0x00007fff4b739000) libicutu.so.59 => /lib64/libicutu.so.59 (0x00007fb515db2000) libicui18n.so.59 => /lib64/libicui18n.so.59 (0x00007fb515938000) libicuuc.so.59 => /lib64/libicuuc.so.59 (0x00007fb51558a000) libicudata.so.59 => /lib64/libicudata.so.59 (0x00007fb513a77000) libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003c7e400000) libdl.so.2 => /lib64/libdl.so.2 (0x0000003c7e800000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003c80c00000) libm.so.6 => /lib64/libm.so.6 (0x0000003c7f000000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003c80000000) libc.so.6 => /lib64/libc.so.6 (0x00007fb5136e8000) /lib64/ld-linux-x86-64.so.2 (0x0000003c7dc00000)
8.再次执行dotnet --version
[root@test bin]# dotnet --version 2.2.101
到这里,终于结束了。!