沉重地升级GLIBC辛酸过程,又名作死记*2
原由
之前一直没有找到好用的 linux 桌面版 v2ray 客户端,直到看到了 v2rayL ,太好看了吧.准备盘它.
但是照着 install.sh 安装完之后,打开却报了 "libc.so.6: version `GLIBC_2.25’ not found"报错. 得知是 GLIBC版本太低.于是开始了骚操作(作死)之路
查看GLIBC版本
我的电脑装的是 ubuntu16.04 64位,可以执行下边的命令查看,最高只有 2.23版本
luopeibin@luo-hp:/lib64$ strings 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_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
升级GLIBC
既然没有,那就升级吧.
# 下载glibc包
wget https://ftp.gnu.org/gnu/glibc/glibc-2.25.tar.gz
# 解压
tar -zxf glibc-2.25.tar.gz
#
cd glibc.2-25 && mkdir build && cd build/
#
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
# make
make
make install
执行make好像报了个小错,缺少一个包,apt-get install 即可,make执行可能有点久,但是 make install 报错了.
果然没有那么顺利, install-symbolic-link failed,但是比想象中要严重!! 接下来无法执行任何命令,报 illegal instruction 非法指令,估计底层的依赖库什么被搞奔溃了.
关键是我还脑子发热觉得重启以下就行了… 次奥
重启,一直卡在关机界面,只有一个小下划线闪烁着,等了好几分钟都一样,无奈,强制重启.grub启动页面倒是正常,只是系统一直无法进入,一直卡在ubuntu 紫色页面.
常规操作,刷新 /boot 分区下的内核文件
初次挽救电脑,之前电脑有做备份. 充分体现的备份的重要性呀
之前几篇博客有提到,但没有讲的比较清楚.这次附上具体操作
首选需要准备个ubuntu启动u盘 ( 幸好电脑是双系统,嘿嘿) ,然后进入bios设置启动项为USB优先
接着 try ubuntu,打开文件管理器,此处 121GB的分区是 我原ubuntu系统 / 目录,我的系统备份文件在这里边. 1.3GB分区是 原ubuntu系统的 /boot/ 路径,每次 install 新的软件什么的,系统都是编译一个新的 vmlinuz 放在此处,而 / 路径下有一个软链接链接到这个 vmlinuzx
然后,将原系统的 /boot下的文件全部删除,将备份目录下的 /boot 文件复制进来
操作就绪后,重启
systemctl power
还是和之前一样,卡在紫色界面,什么恢复模式统统没有用.
内心一紧,次奥,早知道不折腾了,该不会要重装系统吧.
分析
网上google了一下,发现有个老哥升级glibc也出现了类似的错误
添加链接描述
看了一下 elf/symlink.list 文件内容, /lib64/ld-linux-x86-64.so.2 指向了新的版本 2.25
# 这是查看 ld-linux-x86-64 软链接指向哪个动态链接库,已经指向新的版本了
ubuntu@ubuntu:~$ ll /lib64/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 10 8月 22 11:45 /lib64/ld-linux-x86-64.so.2 -> ld-2.25.so*
# 这里查看 ls 这个系统命令依赖的动态链接库
ubuntu@ubuntu:~$ ldd /bin/ls
linux-vdso.so.1 (0x00007ffc07955000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f89a1652000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f89a12b3000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f89a1043000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f89a0e3f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f89a1874000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f89a0c21000)
# 接着 查看libc.so.6 指向的链接是啥
ubuntu@ubuntu:~$ ll /lib/x86_64-linux-gnu/libc.so.6
lrwxrwxrwx 1 root root 10 8月 22 11:45 /lib/x86_64-linux-gnu/libc.so.6 -> libc-2.23.so*
此时发现, /lib64 路径下依赖的库文件都被更新了.但是 /lib/x86_64-linux-gnu/ 链接的都还是老的库文件,他们会互相依赖,所以版本不一致就报错了.
那简单了,我将
# 查看 /lib/x86_64-linux-gnu 下所有依赖老的库的链接.
# 我们将其软链接指向新的版本不就行了吗
ubuntu@ubuntu:/media/ubuntu/b2261f1a-d63f-4b82-8d3f-1df050151ebe/lib/x86_64-linux-gnu$ ll | grep -E 'lib.*-2.23.so' | grep 'lrwxrwxrwx'
lrwxrwxrwx 1 root root 14 Jun 5 15:28 libanl.so.1 -> libanl-2.23.so
lrwxrwxrwx 1 root root 23 Jun 5 15:28 libBrokenLocale.so.1 -> libBrokenLocale-2.23.so
lrwxrwxrwx 1 root root 15 Jun 5 15:28 libcidn.so.1 -> libcidn-2.23.so
lrwxrwxrwx 1 root root 16 Jun 5 15:28 libcrypt.so.1 -> libcrypt-2.23.so
lrwxrwxrwx 1 root root 13 Jun 5 15:28 libdl.so.2 -> libdl-2.23.so
lrwxrwxrwx 1 root root 12 Jun 5 15:28 libm.so.6 -> libm-2.23.so
lrwxrwxrwx 1 root root 15 Jun 5 15:28 libmvec.so.1 -> libmvec-2.23.so
lrwxrwxrwx 1 root root 14 Jun 5 15:28 libnsl.so.1 -> libnsl-2.23.so
lrwxrwxrwx 1 root root 21 Jun 5 15:28 libnss_compat.so.2 -> libnss_compat-2.23.so
lrwxrwxrwx 1 root root 18 Jun 5 15:28 libnss_dns.so.2 -> libnss_dns-2.23.so
lrwxrwxrwx 1 root root 20 Jun 5 15:28 libnss_files.so.2 -> libnss_files-2.23.so
lrwxrwxrwx 1 root root 21 Jun 5 15:28 libnss_hesiod.so.2 -> libnss_hesiod-2.23.so
lrwxrwxrwx 1 root root 22 Jun 5 15:28 libnss_nisplus.so.2 -> libnss_nisplus-2.23.so
lrwxrwxrwx 1 root root 18 Jun 5 15:28 libnss_nis.so.2 -> libnss_nis-2.23.so
lrwxrwxrwx 1 root root 18 Jun 5 15:28 libpthread.so.0 -> libpthread-2.23.so*
lrwxrwxrwx 1 root root 17 Jun 5 15:28 libresolv.so.2 -> libresolv-2.23.so
lrwxrwxrwx 1 root root 13 Jun 5 15:28 librt.so.1 -> librt-2.23.so
lrwxrwxrwx 1 root root 15 Jun 5 15:28 libutil.so.1 -> libutil-2.23.so
# 将 /lib64/ 下新的 libxxx.so 新的版本的库文件复制进 /lib/x86_64-linux-gnu
# 然后重现创建链接
# 此时最好对修改的文件夹备份
sudo ln -sf libanl-2.25.so libanl.so.1
sudo ln -sf libBrokenLocale-2.25.so libBrokenLocale.so.1
sudo ln -sf libcidn-2.25.so libcidn.so.1
sudo ln -sf libcrypt-2.25.so libcrypt.so.1
sudo ln -sf libdl-2.25.so libdl.so.2
sudo ln -sf libm-2.25.so libm.so.6
sudo ln -sf libmvec-2.25.so libmvec.so.1
sudo ln -sf libnsl-2.25.so libnsl.so.1
sudo ln -sf libnss_compat-2.25.so libnss_compat.so.2
sudo ln -sf libnss_dns-2.25.so libnss_dns.so.2
sudo ln -sf libnss_files-2.25.so libnss_files.so.2
sudo ln -sf libnss_hesiod-2.25.so libnss_hesiod.so.2
sudo ln -sf libnss_nisplus-2.25.so libnss_nisplus.so.2
sudo ln -sf libnss_nis-2.25.so libnss_nis.so.2
sudo ln -sf libpthread-2.25.so* libpthread.so.0
sudo ln -sf libresolv-2.25.so libresolv.so.2
sudo ln -sf librt-2.25.so librt.so.1
sudo ln -sf libutil-2.25.so libutil.so.1
sudo ln -sf libnss_db-2.25.so libnss_db.so.1
sudo ln -sf ld-2.25.so* ld-linux-x86-64.so.2
执行完后,满心期待地重启. 果然可以用了,
但是还是无法打开 v2rayLui 客户端,只能再次执行 make install 了
再次执行 make install
此时报的错更是摸不着头脑了
Library libcrypt is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libcrypt.so?
Library libresolv is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libresolv.so?
Library libgcc_s is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libgcc_s.so?
Library libnss_db is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libnss_db.so?
Library libnss_nisplus is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libnss_nisplus.so?
Library libm is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libm.so?
Library libpthread is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libpthread.so?
Library libutil is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libutil.so?
Library libdl is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libdl.so?
Library libnsl is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libnsl.so?
Library librt is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link librt.so?
Library libnss_dns is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libnss_dns.so?
Library libmvec is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libmvec.so?
Library libnss_nis is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libnss_nis.so?
Library libBrokenLocale is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libBrokenLocale.so?
Library libnss_hesiod is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libnss_hesiod.so?
Library libcidn is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libcidn.so?
Library libnss_files is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libnss_files.so?
Library libanl is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libanl.so?
Library libnss_compat is not correctly installed since the test program
was not linked dynamically against it.
Do you have a file/link libnss_compat.so?
finish
看起来像是 这些 libxxx的库在 /lib 和 /usr/lib 下不存在,可是明明就有的呀
luopeibin@luo-hp:/lib64$ ll | grep -E 'lib.*'
-rwxr-xr-x 1 root root 78280 8月 22 11:45 libanl-2.25.so*
lrwxrwxrwx 1 root root 14 8月 22 11:45 libanl.so.1 -> libanl-2.25.so*
-rwxr-xr-x 1 root root 21280 8月 22 11:45 libBrokenLocale-2.25.so*
lrwxrwxrwx 1 root root 23 8月 22 11:45 libBrokenLocale.so.1 -> libBrokenLocale-2.25.so*
-rwxr-xr-x 1 root root 10918888 8月 22 11:45 libc-2.25.so*
-rwxr-xr-x 1 root root 277080 8月 22 11:45 libcidn-2.25.so*
lrwxrwxrwx 1 root root 15 8月 22 11:45 libcidn.so.1 -> libcidn-2.25.so*
-rwxr-xr-x 1 root root 146064 8月 22 11:45 libcrypt-2.25.so*
lrwxrwxrwx 1 root root 16 8月 22 11:45 libcrypt.so.1 -> libcrypt-2.25.so*
lrwxrwxrwx 1 root root 12 8月 22 11:45 libc.so.6 -> libc-2.25.so*
-rwxr-xr-x 1 root root 105296 8月 22 11:45 libdl-2.25.so*
lrwxrwxrwx 1 root root 13 8月 22 11:45 libdl.so.2 -> libdl-2.25.so*
# 太多了,此处省略
luopeibin@luo-hp:/lib64$ ll /lib/x86_64-linux-gnu/ | grep -E 'lib.*'
lrwxrwxrwx 1 root root 15 11月 7 2017 libacl.so.1 -> libacl.so.1.1.0
-rw-r--r-- 1 root root 31232 2月 7 2016 libacl.so.1.1.0
lrwxrwxrwx 1 root root 15 10月 24 2015 libaio.so.1 -> libaio.so.1.0.1
-rw-r--r-- 1 root root 5512 10月 24 2015 libaio.so.1.0.1
-rwxr-xr-x 1 root root 78280 8月 19 23:37 libanl-2.25.so*
lrwxrwxrwx 1 root root 14 8月 19 23:53 libanl.so.1 -> libanl-2.25.so*
lrwxrwxrwx 1 root root 20 5月 29 2019 libapparmor.so.1 -> libapparmor.so.1.4.0
-rw-r--r-- 1 root root 64144 5月 29 2019 libapparmor.so.1.4.0
lrwxrwxrwx 1 root root 20 11月 7 2017 libatasmart.so.4 -> libatasmart.so.4.0.5
# 太多了,此处省略
没办法,只得详细看make install 报错时,前边执行了啥
# 前边执行的操作
LD_SO=ld-linux-x86-64.so.2 CC="gcc -B/usr/bin/" /usr/bin/perl scripts/test-installation.pl /home/luopeibin/Downloads/工具/glibc/glibc-2.25/build/
看起来像是执行了一个perl脚本,然后在里边抛出来的错.
perl脚本根本不懂,这可难倒我了. 语法有点怪异,想想为了 v2rayLui 忍了, 对照着里边的脚本内容,去看看perl教程,整理了以下,加上一些注释,以免看到后边,前边不知道是啥意思了
#!/usr/bin/perl -w
# Copyright (C) 1997-2017 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1997.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# The GNU C Library 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
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.
# 是这么启动的
# LD_SO=ld-linux-x86-64.so.2 CC="gcc -B/usr/bin/" /usr/bin/perl scripts/test-installation.pl /home/luopeibin/Downloads/工具/glibc/glibc-2.25/build/
$PACKAGE = "libc";
$progname = $0;
if ($ENV{CC}) {
$CC = $ENV{CC};
} else {
$CC= "gcc";
}
if ($ENV{LD_SO}) {
$LD_SO = $ENV{LD_SO};
} else {
$LD_SO = "";
}
sub usage {
print "Usage: test-installation [soversions.mk]\n";
print " --help print this help, then exit\n";
print " --version print version number, then exit\n";
exit 0;
}
sub installation_problem {
print "The script has found some problems with your installation!\n";
print "Please read the FAQ and the README file and check the following:\n";
print "- Did you change the gcc specs file (necessary after upgrading from\n";
print " Linux libc5)?\n";
print "- Are there any symbolic links of the form libXXX.so to old libraries?\n";
print " Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,\n";
print " libm.so should point to the newly installed glibc file - and there should be\n";
print " only one such link (check e.g. /lib and /usr/lib)\n";
print "You should restart this script from your build directory after you've\n";
print "fixed all problems!\n";
print "Btw. the script doesn't work if you're installing GNU libc not as your\n";
print "primary library!\n";
exit 1;
}
# @ARGV 传给脚本的命令行参数列表
arglist: while (@ARGV) {
if ($ARGV[0] eq "--v" || $ARGV[0] eq "--ve" || $ARGV[0] eq "--ver" ||
$ARGV[0] eq "--vers" || $ARGV[0] eq "--versi" ||
$ARGV[0] eq "--versio" || $ARGV[0] eq "--version") {
print "test-installation (GNU $PACKAGE)\n";
print "Copyright (C) 2017 Free Software Foundation, Inc.\n";
print "This is free software; see the source for copying conditions. There is NO\n";
print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
print "Written by Andreas Jaeger <aj\@arthur.rhein-neckar.de>\n";
exit 0;
} elsif ($ARGV[0] eq "--h" || $ARGV[0] eq "--he" || $ARGV[0] eq "--hel" ||
$ARGV[0] eq "--help") {
&usage;
} elsif ($ARGV[0] =~ /^-/) {
print "$progname: unrecognized option `$ARGV[0]'\n";
print "Try `$progname --help' for more information.\n";
exit 1;
} else {
last arglist;
}
}
# We expect none or one argument.
# $ARGV[0] 为 /home/luopeibin/Downloads/工具/glibc/glibc-2.25/build/
if ($#ARGV == -1) {
$soversions="soversions.mk";
$config="config.make";
} elsif ($#ARGV == 0) {
# $#ARGV 最大索引
# [ -d FILE ] 如果 FILE 存在且是一个目录则为真
# $soversions = /home/luopeibin/Downloads/工具/glibc/glibc-2.25/build/soversions.mk
# $config = /home/luopeibin/Downloads/工具/glibc/glibc-2.25/build/config.make
if (-d $ARGV[0]) {
$soversions = "$ARGV[0]/soversions.mk";
$config = "$ARGV[0]/config.make";
} else {
$soversions = $dir = $ARGV[0];
$dir =~ s!/?[^/]*/*$!!;
$config = $dir . "/config.make";
}
} else {
die "Wrong number of arguments.";
}
# luopeibin@luo-hp:~/Downloads/工具/glibc/glibc-2.25/build$ grep "build-mathvec = yes" config.make
# build-mathvec = yes
# 判断shell命令是否执行成功
# 故 $build_mathvec = 1;
if (system ("grep -q \"build-mathvec = yes\" $config") == 0) {
$build_mathvec = 1;
} else {
$build_mathvec = 0;
}
# Read names and versions of all shared libraries that are part of
# glibc
# 如果open失败,die会终止程序的运行,并且告诉我们无法创建日志文件
# open FILEHANDLE, EXPR
# FILEHANDLE:文件句柄,用于存放一个文件唯一标识符
# EXPR:文件名及文件访问类型组成的表达式
open SOVERSIONS, $soversions
or die ("Couldn't open $soversions in build directory!");
$link_libs = "";
%versions = ();
# 最常用的特殊变量为 $_,该变量包含了默认输入和模式匹配内容
# 默认情况下使用的也是 $_
while (<SOVERSIONS>) {
# next 类似于 continue
# 判断当前行是 all-sonames 开头则跳过
next if (/^all-sonames/);
# 去掉空行?
chop;
# lib开头
if (/^lib/) {
# libnss_hesiod.so-version=.2
# 分别获取 ness_hesiod 和 2
($name, $version)= /^lib(.*)\.so-version=\.(.*)$/;
# Filter out some libraries we don't want to link:
# - nss_ldap since it's not yet available
# - libdb1 since it conflicts with libdb
# - libnss1_* from glibc-compat add-on
# - libthread_db since it contains unresolved references
# - it's just a test NSS module
# - We don't provide the libgcc so we don't test it
# - libmvec if it wasn't built
next if ($build_mathvec == 0 && $name eq "mvec");
if ($name ne "nss_ldap" && $name ne "db1"
&& !($name =~/^nss1_/) && $name ne "thread_db"
&& $name ne "nss_test1" && $name ne "libgcc_s") {
# .= 就是 +=吧
# 保存在 versions hash表中
$link_libs .= " -l$name";
$versions{$name} = $version;
}
} elsif ($LD_SO ne "") {
# 当前 $LD_SO 有值,所以走这里 获取 ld 名字和版本
# $ld_so_name=ld-linux-x86-64
# $ld_so_version=2
($ld_so_name, $ld_so_version) = split ('\.so\.', $LD_SO);
} else {
if (/^ld\.so/) {
($ld_so_name, $ld_so_version)= /=(.*)\.so\.(.*)$/;
}
}
}
close SOVERSIONS;
# Create test program and link it against all
# shared libraries
# $$ 应该是当前进程id
# 写入一个测试demo
open PRG, ">/tmp/test-prg$$.c"
or die ("Couldn't write test file /tmp/test-prg$$.c");
print PRG '
#include <stdio.h>
#include <stdlib.h>
int main(void) {
printf ("Your new glibc installation seems to be ok.\n");
exit (0);
}
';
close PRG;
# CC="gcc -B/usr/bin/"
# 使用gcc编译成可执行文件
open GCC, "$CC /tmp/test-prg$$.c $link_libs -o /tmp/test-prg$$ 2>&1 |"
or die ("Couldn't execute $CC!");
while (<GCC>) {
print $_ if (! /warning/);
}
close GCC;
if ($?) {
print "Execution of $CC failed!\n";
&installation_problem;
}
# Test if test program is linked against the right versions of
# shared libraries
$ok = 1;
%found = ();
open LDD, "ldd /tmp/test-prg$$ |"
or die ("Couldn't execute ldd");
#luopeibin@luo-hp:/tmp$ ldd test-prg20765
# linux-vdso.so.1 (0x00007ffd373c7000)
# libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4388ff7000)
# /lib64/ld-linux-x86-64.so.2 (0x00007f4389396000)
while (<LDD>) {
if (/^\s*lib/) {
($name, $version1, $version2) =
/^\s*lib(\w*)\.so\.([0-9\.]*)\s*=>.*\.so\.([0-9\.]*)/;
$found{$name} = 1;
if ($versions{$name} ne $version1 || $version1 ne $version2) {
print "Library lib$name is not correctly installed.\n";
print "Please check your installation!\n";
print "Offending line of ldd output: $_\n";
$ok = 0;
}
}
if (/$ld_so_name/) {
($version1) = /$ld_so_name\.so\.([0-9\.]*)/;
if ($version1 ne $ld_so_version) {
print "The dynamic linker $ld_so_name.so is not correctly installed.\n";
print "Please check your installation!\n";
print "Offending line of ldd output: $_\n";
$ok = 0;
}
}
}
close LDD;
die "ldd execution failed" if $?;
# 抛出问题是在介里.
# %versions 是一个hash对象,遍历的里边的值,然后在 $found这个hash对象中查找,如果没有找到就会报前边的错误.
foreach (keys %versions) {
unless ($found{$_}) {
print "Library lib$_ is not correctly installed since the test program\n";
print "was not linked dynamically against it.\n";
print "Do you have a file/link lib$_.so?\n";
$ok = 0;
}
}
&installation_problem unless $ok;
# Finally execute the test program
system ("/tmp/test-prg$$") == 0
or die ("Execution of test program failed");
# Clean up after ourselves
unlink ("/tmp/test-prg$$", "/tmp/test-prg$$.c");
注意到抛出异常的地方在介里
# 抛出问题是在介里.
# %versions 是一个hash对象,遍历的里边的值,然后在 $found这个hash对象中查找,如果没有找到就会报前边的错误.
foreach (keys %versions) {
unless ($found{$_}) {
print "Library lib$_ is not correctly installed since the test program\n";
print "was not linked dynamically against it.\n";
print "Do you have a file/link lib$_.so?\n";
$ok = 0;
}
}
大概的操作是 将 $soversions = /home/luopeibin/Downloads/工具/glibc/glibc-2.25/build/soversions.mk 文件的内容解析成 %versions变量
然后生成一个 test.c 使用 gcc 编译成一个可执行文件,然后 ldd查看该执行文件,查看依赖的动态库文件,然后解析成 %found对象,最后做对比.
我在本地试了一下,
1 #include <stdio.h> /* printf */
2 #include <math.h> /* cos */
3 #define PI 3.14159265
4 int main ()
5 {
6 double param, result;
7 param = 60.0;
8 //result = cos ( param * PI / 180.0 );
9 result=12.0;
10 printf ("The cosine of %f degrees is %f.\n", param, result );
11 return 0;
12 }
很简单的程序,使用到了 cos函数,该函数是在动态链接库 libm.so中的
gcc -lm 实际上就是指向 libm这个库
luopeibin@luo-hp:~/Desktop/pl_test$ ls
main.c
luopeibin@luo-hp:~/Desktop/pl_test$ gcc main.c -lm
luopeibin@luo-hp:~/Desktop/pl_test$ ls
a.out main.c
luopeibin@luo-hp:~/Desktop/pl_test$ ldd a.out
linux-vdso.so.1 (0x00007ffd27d4a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff33921e000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff3395bd000)
但程序中使用了 cos函数,但是编译时没有指定 -lm 添加libm这个动态链接库时会报错.而当没有使用 cos函数,而我指定了 -lm 这个库时,生成的程序所依赖的库本来就不会包含 libm这个库啊.
又去google里一番,发现 ubuntu 默认会给 gcc 添加 -Wl,–as-needed 优化,应该是代表只有库文件被使用到了才会在程序中依赖此库文件. 可以使用 -Wl,–no-as-needed 防止这个优化
那么就在这行加上把
open GCC, "$CC /tmp/test-prg$$.c -Wl,--no-as-needed $link_libs -o /tmp/test-prg$$ 2>&1 |"
or die ("Couldn't execute $CC!");
再执行一次 make install ,终于成功了 我的马呀
最后再执行以下 v2rayLui 还是报 . 无奈脸
luopeibin@luo-hp:/usr/bin/v2rayL$ ./v2rayLui
Aborted (core dumped)
卸载 python3.5
默认ubuntu16.04 装了python3.5 ,但是v2rayLui 依赖python3.6 ,可能是这个原因
然后执行了下边的命令.
但是各位千万不要去执行
各位千万不要执行!!!
各位千万不要执行!!!
各位千万不要执行!!!
sudo apt-get autoremove python3.5
执行了后就怪怪的,在卸载列表里看到了mysql???,然后字体变了,打开不了新的terminal了.还以为是出 bug了,重启后还是一样,terminal无法打开.
含着泪google才知道,ubuntu里边有很多程序依赖于python,比如ubuntu-desktop桌面
只能进入 tty1执行修复了,看到tty1终端中文乱码,于是修改了 /etc/default/locale
1 # File generated by update-locale
2 #LANG="zh_CN.UTF-8"
3 #LANGUAGE="zh_CN:zh"
4
5 LANG="en_US.UTF-8"
6 LANGUAGE="en_US:en"
执行
apt-get install -f
apt-get install python3.5
apt-get install ubuntu-minimal ubuntu-standard ubuntu-desktop
进入tty7终于可以进入桌面了,但是发现很多软件不见了 …
比如 chrome,sogou pinyin,mysql,docky…
次奥,再也不作死了,再也不装v2rayLui了.就算电脑炸掉,从楼顶掉下去,也绝对不作死了
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
真香!
“还是把 ubuntu16.04 升级到 18.04吧”