云网牛站
所在位置:首页 > Linux教程 > CentOS 7安装C语言编译器gcc和c++及出现的问题解决

CentOS 7安装C语言编译器gcc和c++及出现的问题解决

2018-08-13 14:50:48作者:达之领域稿源:linux站

以下为你介绍在CentOS 7操作系统中安装C语言编译器gcc、gcc-c++的方法,只需要一个命令,及解决在安装过程中出现的问题。

 

一、安装C语言编译器

在CentOS 7系统终端中输入:yum install -y gcc,进行安装,如图:

CentOS 7安装C语言编译器gcc和c++及出现的问题解决

安装完后再安装c++编译器,系统终端中输入:yum install -y gcc-c++,安装后当然要检查下是否配置成功:

CentOS 7安装C语言编译器gcc和c++及出现的问题解决

CentOS 7安装C语言编译器gcc和c++及出现的问题解决

分别再输入gcc -v和g++ -v,检查看到上两张图的配置已经成功,这样CentOS 7 Linux平台可以正式使用。

 

二、Linux安装编译器时出现的问题

如果安装编译器时出现以下情况:

安装编译器指令:yum install -y gcc

已加载插件:fastestmirror, langpacks

One of the configured repositories failed (未知),

and yum doesn't have enough cached data to continue. At this point the only

safe thing yum can do is fail. There are a few ways to work "fix" this:

1.Contact the upstream for the repository and get them to fix the problem.

2.Reconfigure the baseurl/etc. for the repository, to point to a working

upstream. This is most often useful if you are using a newer

distribution release than is supported by the repository (and the

packages for the previous distribution release still work).

3.Disable the repository, so yum won't use it by default. Yum will then

just ignore the repository until you permanently enable it again or use

--enablerepo for temporary usage:

yum-config-manager --disable <repoid>

4.Configure the failing repository to be skipped, if it is unavailable.

Note that yum will try to contact the repo. when it runs most commands,

so will have to try and fail each time (and thus. yum will be be much

slower). If it is a very temporary problem though, this is often a nice

compromise:

yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

翻译:配置存储库失败之一(未知)

而且yum没有足够的缓存数据来继续。此时,yum能做的唯一安全的事情就是失败。有几种方法可以“修复”这个问题:

1.联系上游的存储库并让他们解决问题。

2.重新配置baseurl等。对于存储库,指向正在工作的上游。如果您使用的是新的发行版,而不是存储库支持的,那么这通常是非常有用的。(以前发行版的包仍然有效)。

3.禁用存储库,这样yum在默认情况下不会使用它。然后Yum将忽略存储库直到您永久地再次启用它或使用—enablerepo作为临时使用:< repoid yum-config-manager——禁用

4.配置要跳过的失败存储库,如果它不可用。请注意,yum将尝试联系repo。当它运行大多数命令时,每次都要尝试失败。(因此。yum将会慢得多。)如果这只是一个暂时的问题,这通常是一个很好的妥协(解决问题):yum-config-manager——保存——setopt = < repoid >。跳过如果用时= true

无法找到有效的baseurl:base/7/x86_64

原因:网络网卡虽然开启,但是依旧没有网络(没有足够的网络数据支持),有时候挂载网络也是没有用的。

解决方案:创建虚拟机时网络选择时不选桥接,选择默认的。

ps:我在网上查过诸多的资料,有的人说在网卡文件上加上DNS地址和一个备用地址,我用了也不行,有的人说yum源配置出错,重新下载安装,但是网上大部分的网址都是失效的,而且也很难找到属于自己的,所以建议使用我提供的镜像文件,亲测有效,虚拟机网络选择不要选桥接,默认即可。

 

相关主题

CentOS下安装高版本GCC

精选文章
热门文章