初次安装系统后,需要配置一下yum本地源,这是因为,我们需要的软件系统默认安装过程中许多软件没有安装

1:配置本地yum源

配置本地yum源是通过本地映射光盘挂载到系统中,然后将yum的配置文件中的 baseurl 指向挂载的目录即可。

首先在虚拟机的这个配置中,勾选使用iso映射文件,然后选中我们iso文件所在的位置即可。

在虚拟机系统中,我们的 iso 文件是 /dev/sr0 设备,系统会默认把我们的iso文件挂载到 /run/media/$username/ 目录下。但是现在我们要将iso文件挂载到 /mnt/cdrom 下。如果mnt目录下没有cdrom,那么我们自己新建一个。

挂载有两种方式挂载

  • 一次性挂载,重启完系统后失效
[root@localhost c]# mkdir /mnt/cdrom
[root@localhost c]# mount -t iso9660 /dev/sr0 /mnt/cdrom/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost c]# ls /mnt/cdrom/
addons            GPL       media.repo               RPM-GPG-KEY-redhat-release
EFI               images    Packages                 TRANS.TBL
EULA              isolinux  repodata
extra_files.json  LiveOS    RPM-GPG-KEY-redhat-beta

  • 自动挂载

在末行添加如下代码:

/dev/sr0                /mnt/cdrom              iso9660 defaults        0 0

然后保存退出

挂载好iso文件之后,我们在 /etc/yum.repos.d/ 下创建一个repo结尾的文件

cd /etc/yum.repos.d
vim cdrom.repo

修改内容如下:

[cdrom]
name=cdrom
baseurl=file:///mnt/cdrom
enable=1
gpgcheck=0

保存退休vim后,运行如下命令(可以看到本地源已经启用了):

[root@localhost yum.repos.d]# yum repolist all
已加载插件:langpacks, product-id, search-disabled-repos, subscription-managerThis system is not registered with an entitlement server. You can use subscription-manager to register.源标识                                源名称                                状态
cdrom                                 cdrom                                 启用: 5,231
repolist: 5,231
[root@localhost yum.repos.d]#

使用本地yum源安装gcc,c++

yum install gcc gcc-c++

查看安装的gcc,c++版本

[root@localhost yum.repos.d]# gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
[root@localhost yum.repos.d]# c++ -v
使用内建 specs。
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
[root@localhost yum.repos.d]#

2:扩展gcc,c++的32位支持

gcc,c++安装过后,使用-m32时会出错,其实是系统没有安装32位库支持,使用下面命令试gcc,c++支持32编译。部分低版本,需要网络下载相应的软件包安装。

yum install glibc-devel.i686 glibc-devel libgcc.i686 libstdc++.i686 libstdc++-devel.i686

3:扩展gcc,c++的静态库支持

静态库需要打开下面打开这个网站: (这个网站内容比较全)

https://www.rpmfind.net/linux/RPM/index.html​www.rpmfind.net

一些备用的rpm库下载地址:

RPM Search​rpm.pbone.net

下载下面4个软件包

glibc-static-2.17-307.el7.1.i686.rpm    libstdc++-static-4.8.5-39.el7.i686.rpm
glibc-static-2.17-307.el7.1.x86_64.rpm  libstdc++-static-4.8.5-39.el7.x86_64.rpm

安装4个软件包

rpm -ivh glibc-* libstdc++*

4:测试如下

c文件源代码:hello.c

#include <stdio.h>int main(void)
{printf("hello world!n");return 0;
}

c语言编译运行:

[root@localhost c]# gcc -Wall -std=c99 -o hello hello.c
[root@localhost c]# gcc -Wall -std=c99 -m32 -o hello_x86 hello.c
[root@localhost c]# gcc -Wall -std=c99 -static -o hello_static hello.c
[root@localhost c]# gcc -Wall -std=c99 -static -m32 -o hello_static_x86 hello.c
[root@localhost c]# ll
总用量 1624
-rwxr-xr-x. 1 root root   8360 6月  26 20:37 hello
-rw-r--r--. 1 root root     79 6月  26 18:56 hello.c
-rwxr-xr-x. 1 root root 861104 6月  26 20:37 hello_static
-rwxr-xr-x. 1 root root 773916 6月  26 20:37 hello_static_x86
-rwxr-xr-x. 1 root root   7216 6月  26 20:37 hello_x86
[root@localhost c]# file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0def4001abbd8d813e084fb05dd5a86dd7a1ec39, not stripped
[root@localhost c]# file hello_x86
hello_x86: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=6007c1f4e7d015516f55b4d7094947eb19aed590, not stripped
[root@localhost c]# file hello_static
hello_static: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=efd6d1b6b4b499c76a90c81ada2f1a8eed74a1bf, not stripped
[root@localhost c]# file hello_static_x86
hello_static_x86: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=85d90d2fd7463ef8cc39270c26ba256c1771a29c, not stripped
[root@localhost c]# ^C
[root@localhost c]# ./hello
hello world!
[root@localhost c]# ./hello_static
hello world!
[root@localhost c]# ./hello_x86
hello world!
[root@localhost c]# ./hello_static_x86
hello world!
[root@localhost c]#

C语言测试完全没有问题。接下来看C++

c++源代码:

#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::ends;
using std::clog;
using std::cerr;int main(void)
{cout << "hello world" << endl;return 0;
}

C++编译测试:

[root@localhost cpp]# g++ -Wall -std=c++0x -o hello hello.cpp
[root@localhost cpp]# g++ -Wall -std=c++0x -m32 -o hello_x86 hello.cpp
[root@localhost cpp]# g++ -Wall -std=c++0x -static -o hello_static hello.cpp
[root@localhost cpp]# g++ -Wall -std=c++0x -static -m32 -o hello_static_x86 hello.cpp
[root@localhost cpp]# ll
总用量 3092
-rwxr-xr-x. 1 root root    9024 6月  26 20:41 hello
-rw-r--r--. 1 root root     186 6月  26 19:39 hello.cpp
-rwxr-xr-x. 1 root root 1608232 6月  26 20:42 hello_static
-rwxr-xr-x. 1 root root 1530996 6月  26 20:42 hello_static_x86
-rwxr-xr-x. 1 root root    7780 6月  26 20:42 hello_x86
[root@localhost cpp]# file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=bcee8282c15a3c4f321d54536fe3d985db8b21fb, not stripped
[root@localhost cpp]# file hello_x86
hello_x86: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=2d33e1d331b061f868b64dbf3c5801f6c9d32a64, not stripped
[root@localhost cpp]# file hello_static
hello_static: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=ec0b102d67b7ada6ee452c0b17ae480230f699de, not stripped
[root@localhost cpp]# file hello_static_x86
hello_static_x86: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=0a161fb9d6f37d019254c46fdeed0da0457158c2, not stripped
[root@localhost cpp]# ./hello
hello world
[root@localhost cpp]# ./hello_x86
hello world
[root@localhost cpp]# ./hello_static
hello world
[root@localhost cpp]# ./hello_static_x86
hello world
[root@localhost cpp]#

C++测试也没有问题。至此C,C++32位以及静态编译支持完工。

dev c++ 64位_RHEL7.8添加本地源以及扩展GCC,C++的32位和静态库支持相关推荐

  1. 无法安装64位版本的office_手机微信有两个版本,32位和64位,你的微信是多少位?...

    之前我就为大家分享了,如何查看自己的微信是32位还是64位,我们只需要在微信的设置-关于微信,进入后我们只需要将版本号上的微信图标双击就能查看了,如下图所示: 如果你的微信这里显示为 armeabi- ...

  2. 32位单片机 一个32位地址代表一个字节而不是4个字节(32位)

    在数据手册上,BSRR的偏移地址为0X18,然后手册讲完BSRR后直接讲LCKR了,并且LCKR的偏移地址是 OX1C .所以根据 OX1C-0X18=0X04 就知道BSRR是32位寄存器了.因为一 ...

  3. linux 添加本地源,linux 添加本地yum源

    1.yum repolist 2.https://opsx.alibaba.com/mirror,首先下在该镜像站点中的yum,这里选择epel源 epel-release-latest-7.noar ...

  4. poatman32位下载_Postman.dll下载|Postman.dll下载官方版【32位|64位】-太平洋下载中心...

    Postman.dll使用方法: 方法一 一.如果在运行某软件或编译程序时提示缺少.找不到Postman.dll等类似提示,您可将从太平洋下载中心下载来的Postman.dll拷贝到指定目录即可(一般 ...

  5. 中文输入法 linux 下载64位,最新搜狗输入法linux版v2.2.0.0108 官方版(32位+64位)下载地址电脑版-锐品软件...

    快速精准,更加出色!搜狗输入法linux版全新发布!提供了模糊拼音.最新词库.云端输入.自动纠错.多彩皮肤.长词联想.网址输入.简繁切换等功能,本站提供了32位+64位搜狗linux输入法下载,请根据 ...

  6. ubuntu 64上的GCC如何编译32位程序

    运行命令 gcc -v 显示: Target: x86_64-linux-gnu 所以,我这里的gcc默认生成64位的程序. 如果想编出32位的程序,就要加 -m32选项.可是我尝试了,还是不行. 原 ...

  7. 您没有足够的全新为该计算机所有用户安装,很抱歉,无法安装Office(64位),因为您的计算机上已经安装了这些32位Office程序解决办法...

    64位与32位版本的Office程序不兼容,因此您一次只能安装一种类型,请尝试改为安装32位版本的Office ,或卸载其他32位Office 程序,然后再次尝试此安装. 在安装Office 2016 ...

  8. 怎么知道电脑是32位还是64位_vnc 64位远程控制软件,你用的vnc 远程控制软件是32位还是64位?...

    任何工具一般都是分为32位或者64位的,因为有的电脑系统是32位有的电脑系统是64位.不知道你是用vnc 远程控制软件使用的多不多,但是现在一般电脑都是64位的,所以使用vnc 64位远程控制软件的肯 ...

  9. java虚拟机32位_jre1.6java虚拟机运行环境下载|jre1.6官方版32位/64位下载_v1.6.0_9号软件下载...

    jre1.6是Java Runtime Environment缩写,指Java运行环境,是Sun的产品.运行JAVA程序所必须的环境的集合,包含JVM标准实现及Java核心类库. 软件介绍 不少软件采 ...

最新文章

  1. 【HTTPS】Let's Encrypt certbot renew
  2. SQLite介绍、学习笔记、性能测试
  3. Spring学习(八)AOP详解
  4. vue node --- 前后端联系的知识梳理
  5. 微软重组变两大事业部:Windows主管离职
  6. 使用Spring JDBC时遇到的Software caused connection abort: recv failed问题
  7. 王传福回应“芯片短缺”:比亚迪没有受到丝毫影响
  8. Windows核心编程:第7章 线程调度、优先级和关联性
  9. 中国数码相机镜头行业市场供需与战略研究报告
  10. .NET 指南:属性与方法之间的选择
  11. 一文读懂华为智能网联汽车产业链布局
  12. ViewPage动态删除页面
  13. 联盟链之hyperledger-fabric
  14. IPSec IKEv1IKEv2
  15. openstack neutron相关命令出现异常HttpException: 503
  16. c语言大作业矩阵运算,用C语言实现矩阵运算
  17. vts传感器采取船舶的_在VTS系统中实现雷达信息与AIS信息融合的方法探讨
  18. opencv medianBlur均值滤波
  19. 1147 简单评委打分
  20. 看的懂的scipy.sparse.csr_matrix和scipy.sparse.csc_matrix

热门文章

  1. easyui datagrid 返回数据正确 fit='true' 时不显示内容
  2. hibernate ORM related
  3. Androidの多线程之更新ui(AsyncTask)
  4. Chrome OS与平板电脑才是珠联璧合
  5. Spring中的AOP在Advice方法中获取目标方法的参
  6. linux netstat 查看网络信息 实例 状态说明
  7. linux gdb调试问题汇总
  8. linux c 函数 link symlink unlink 链接相关功能
  9. Linux2.6--Linus电梯
  10. C语言实现修改文本文件中的特定行