Linux 编译安装libc.so.6时出现Segmentation fault (core dumped)错误导致ls等命令不能用怎么办?

在学校集群上装tensorflow,import tensorflow时出现ImportError: /lib64/libc.so.6: version `GLIBC_2.16' not found,网上查资料按以下步骤进行操作:

(1)下载glibc-2.16.0.tar.bz并解压为 ~/Download/glibc-2.16.0

(2)cd ~/Download/glibc-2.16.0/

 mkdir build

 cd build

 ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

 make

(3) make install时出现错误:

......

......

图片说明

图片说明

如图所示:

(1)make install 时出现错误:make[1]: *** [install] Segmentation fault (core dumped)

(2)ls等命令无法使用,显示缺少version `GLIBC_2.14'

(3)尝试gdb调试,结果显示与(2)中一样的问题

另外,系统本来的libc.so.6链接到libc-2.12.so,最高到GLIBC_2.12,由此看来libc-2.16好像已经安装了一部分。

求各路大神帮帮小弟!!!在线等,挺急的!!!不管是把glibc-2.16安装好还是回退到原来的版本都可以,目的只有一个,那就是让ls,cp,gdb等命令能正常使用。

集群linux版本(red hat)太低了,用起来太麻烦,把系统修复好之后我就不折腾了。

你这个问题确实有点麻烦大了,原因主要是因为你系统里的一些使用到c库的所有程序都肯定是用旧版编译的,而你在安装新版C库时却在安装时出了错(或者库是安装成功了,但不兼容),导致安装没成功,却把旧版的库给替换了(也可能是没有替换只是链接给改了),这就进入了死循环了,你所有命令几乎都执行不了,包括make都不行,所以现在的解决办法只能是进到不依赖你现有系统中C库的命令行中去把C库的链接(或文件)还原成你原来的备份版,这只能使用拯救光盘方式才能实现了,如果你没有光盘,就在开机时直接进入到恢复模式进到命令行,看那些关键命令是否可用,如果可用就直接解决了,不行的话,只能用光盘了。

https://blog.csdn.net/Konaji/article/details/69946794

因为安装时的依赖包特别多,所以建议使用yum命令安装。需要联网。yum在使用的时候,redhat官方的yum源是需要注册收费的。所以建议先切换yum源,比如切换成国内的阿里云yum源。我的博客中有切换方法。或你可以自己到网上查,切换好后再使用yum安装,自动下载依赖包,自动安装。百试不爽、


 
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/epoll.h>
void http_parse_request_cmd(char *buf, char *file_name, char *suffix);
char*http_get_type_by_suffix(const char*suffix);
int fsize(FILE *fp);
struct doc_type{
char*suffix;
char*type;};
struct doc_type file_type[]=
{
{"html","text/html"},
{"ico","image-xicon"},
{NULL,NULL}};
char*http_res_hdr_tmpl="HTTP/1.1 200 OK\nServer: bianchengbang\n"
"Accept-Ranges: bytes\nContent-Length: %d\nConnection: closed\n"
"Content-Type: %s\n\n";
int main(){
int serv_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in serv_addr;
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr =  inet_addr("192.168.137.128");
serv_addr.sin_port = htons(1234);
int isbind=bind(serv_sock, (struct sockaddr*)&serv_addr,sizeof(serv_addr));
 
if (listen(serv_sock, 20) == -1) {
printf("listen errno\n");
close(serv_sock);
return 0;
}
int epfd=epoll_create(50);
struct epoll_event event;
struct epoll_event* ep_events=(struct epoll_event*)malloc(sizeof(struct epoll_event) * 50);
event.events = EPOLLIN;
event.data.fd = serv_sock;
epoll_ctl(epfd, EPOLL_CTL_ADD, serv_sock, &event);
while(1){
int event_cnt = epoll_wait(epfd, ep_events, 50, -1);
if (event_cnt == -1) {
printf("epoll_wait() errno\n");
break;
}
for (int i = 0; i < event_cnt; i++) {
if (ep_events[i].data.fd == serv_sock) {
struct sockaddr_in clnt_addr;
socklen_t adr_sz=sizeof(clnt_addr);
int clnt_sock = accept(serv_sock, (struct sockaddr*)&clnt_addr, &adr_sz);
event.events = EPOLLIN;
event.data.fd = clnt_sock;
epoll_ctl(epfd, EPOLL_CTL_ADD, clnt_sock, &event);
}
else{
char buf[300]={0};
memset(buf, 0, 300);
int num=read(ep_events[i].data.fd, buf, 100);
if(num>0){
char file_name[100]={0};
memset(file_name, 0, 100);
char suffix[100]={0};
memset(suffix, 0, 100);
if(buf[0] == 'G' && buf[1] == 'E' && buf[2] == 'T')
{
http_parse_request_cmd(buf, file_name, suffix);
FILE *fp;
if(file_name == NULL || (fp = fopen(file_name, "rb"))==NULL){
printf("服务器不存在%s文件",file_name);
fp=fopen("errno.html", "rb");
memset(suffix, 0, 100);
strcpy(suffix, "html");
}
else{
printf("服务器存在%s文件,发送中...",file_name);
}
int n=0;
if(fp)
{
    n = fsize(fp);
    char*type=http_get_type_by_suffix(suffix);
    memset(buf, 0, 300);
    if(n>300)n=300;
    sprintf(buf,http_res_hdr_tmpl,n,type);
    write(ep_events[i].data.fd,buf,strlen(buf));
    memset(buf, 0, 300);
    fread(buf, 1,n,fp);
    write(ep_events[i].data.fd,buf,n);
    shutdown(ep_events[i].data.fd,SHUT_WR);
    fclose(fp);
}
}
}
else{
epoll_ctl(epfd, EPOLL_CTL_DEL, ep_events[i].data.fd, NULL);
close(ep_events[i].data.fd);}
}
}
}
close(serv_sock);
close(epfd);
return 0;
}
int fsize(FILE *fp){
    int n;
    fpos_t fpos;  
    fgetpos(fp, &fpos);  
    fseek(fp, 0, SEEK_END);
    n = ftell(fp);
    fsetpos(fp,&fpos);  
    return n;
}
void http_parse_request_cmd(char *buf, char *file_name, char *suffix)
{
int file_length = 0, suffix_length = 0;
char *begin = NULL, *end = NULL, *bias = NULL;
begin = strchr(buf, ' ');
begin += 1;
end = strchr(begin, ' ');
*end = 0;
file_length = end - begin - 1;
memcpy(file_name, begin + 1, file_length);
file_name[file_length] = 0;
bias = strrchr(begin, '/');
suffix_length = end - bias;
if (bias && *bias == '/')
{
bias++;
suffix_length--;
}
if (suffix_length > 0)
{
begin = strchr(file_name, '.');
if (begin)
strcpy(suffix, begin + 1);
}
}
char*http_get_type_by_suffix(const char*suffix)
{int i;
for(i=0;file_type[i].suffix;i++){
if(!strcmp(file_type[i].suffix,suffix))
return file_type[i].type;
}
return NULL;
}
 

另外,在程序运行目录下放一个errno.html返回文件不存在时的html页面。不然会存在返回错误。
如有帮助,请采纳!