centos7 编译gcc -回复

合集下载

centos7 编译gcc

centos7 编译gcc

centos7 编译gcc在CentOS 7上编译GCC需要进行一些步骤。

首先,您需要确保您的系统已经安装了必要的依赖项。

这些依赖项包括Bison、Flex、Libiberty、Texinfo和gettext。

您可以使用以下命令安装这些依赖项:```shellsudo yum install bison flex libiberty texinfo gettext```接下来,您需要从GCC的官方网站下载源代码。

您可以使用wget或curl命令来下载源代码。

例如GCC 9.3.0下载完成后,您需要解压缩源代码。

您可以使用以下命令来解压缩:```shelltar -zxvf gcc-9.3.0.tar.gz```现在,您已经准备好开始编译GCC了。

您可以使用以下命令来配置和编译GCC:```shellcd gcc-9.3.0./configure --prefix=/usr/local/gcc-9.3.0makesudo make install```这将配置GCC,编译它,并将编译后的文件安装到指定的目录中。

请注意,在运行configure命令时,您可以选择不同的选项来自定义您的GCC构建。

您可以查看GCC的官方文档以了解更多信息。

完成编译和安装后,您可以通过运行以下命令来验证GCC是否成功安装:```shell/usr/local/gcc-9.3.0/bin/gcc --version```这将显示已安装的GCC版本信息。

如果您看到正确的版本信息,则表示您已成功在CentOS 7上编译和安装了GCC。

1。

交叉编译工具aarch64-linux-gnu-gcc

交叉编译工具aarch64-linux-gnu-gcc

交叉编译⼯具aarch64-linux-gnu-gcc[root@centos7 arm]# wget https:///-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf.tar.xz--2022-03-0907:12:23-- https:///-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf.tar.xzResolving ()... 23.76.74.223Connecting to ()|23.76.74.223|:443... connected.HTTP request sent, awaiting response... 302 Moved TemporarilyLocation: https:///developer/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf.tar.xz [following]--2022-03-0907:12:24-- https:///developer/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf.tar.xzResolving ()... 52.239.137.100Connecting to ()|52.239.137.100|:443... connected.HTTP request sent, awaiting response... 200 OKLength: 93906188 (90M) [application/octet-stream]Saving to: ‘gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf.tar.xz’100%[============================================================================================================================================================================= 2022-03-0907:12:41 (5.66 MB/s) - ‘gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf.tar.xz’ saved [93906188/93906188][root@centos7 arm]# uname -aLinux centos7 4.14.0-115.el7a.0.1.aarch64 #1 SMP Sun Nov 2520:54:21 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux[root@centos7 arm]#[root@centos7 arm]# ls gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf10.3-2021.07-aarch64-aarch64-none-elf-manifest.txt aarch64-none-elf bin include lib libexec share[root@centos7 arm]# ls gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-addr2line aarch64-none-elf-c++filt aarch64-none-elf-gcc aarch64-none-elf-gcc-ranlib aarch64-none-elf-gdb aarch64-none-elf-ld aarch64-none-elf-objcopy aarch64-none-elf-sizeaarch64-none-elf-ar aarch64-none-elf-cpp aarch64-none-elf-gcc-10.3.1 aarch64-none-elf-gcov aarch64-none-elf-gdb-add-index aarch64-none-elf-ld.bfd aarch64-none-elf-objdump aarch64-none-elf-stringsaarch64-none-elf-as aarch64-none-elf-elfedit aarch64-none-elf-gcc-ar aarch64-none-elf-gcov-dump aarch64-none-elf-gfortran aarch64-none-elf-lto-dump aarch64-none-elf-ranlib aarch64-none-elf-stripaarch64-none-elf-c++ aarch64-none-elf-g++ aarch64-none-elf-gcc-nm aarch64-none-elf-gcov-tool aarch64-none-elf-gprof aarch64-none-elf-nm aarch64-none-elf-readelf[root@centos7 arm]# ls gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gaarch64-none-elf-g++ aarch64-none-elf-gcc-10.3.1 aarch64-none-elf-gcc-nm aarch64-none-elf-gcov aarch64-none-elf-gcov-tool aarch64-none-elf-gdb-add-index aarch64-none-elf-gprofaarch64-none-elf-gcc aarch64-none-elf-gcc-ar aarch64-none-elf-gcc-ranlib aarch64-none-elf-gcov-dump aarch64-none-elf-gdb aarch64-none-elf-gfortran[root@centos7 arm]# ls gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gccaarch64-none-elf-gcc aarch64-none-elf-gcc-10.3.1 aarch64-none-elf-gcc-ar aarch64-none-elf-gcc-nm aarch64-none-elf-gcc-ranlib[root@centos7 arm]# ls gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gcc -versionls: invalid option -- 'e'Try 'ls --help'for more information.[root@centos7 arm]# gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gcc -versionaarch64-none-elf-gcc: error: unrecognized command-line option '-version'aarch64-none-elf-gcc: fatal error: no input filescompilation terminated.[root@centos7 arm]# gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gcc -haarch64-none-elf-gcc: error: missing argument to '-h'aarch64-none-elf-gcc: fatal error: no input filescompilation terminated.[root@centos7 arm]# gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gcc --helpUsage: aarch64-none-elf-gcc [options] file...Options:-pass-exit-codes Exit with highest error code from a phase.--help Display this information.--target-help Display target specific command line options.--help={common|optimizers|params|target|warnings|[^]{joined|separate|undocumented}}[,...].Display specific types of command line options.(Use '-v --help' to display command line options of sub-processes).--version Display compiler version information.-dumpspecs Display all of the built in spec strings.-dumpversion Display the version of the compiler.-dumpmachine Display the compiler's target processor.-print-search-dirs Display the directories in the compiler's search path.-print-libgcc-file-name Display the name of the compiler's companion library.-print-file-name=<lib> Display the full path to library <lib>.-print-prog-name=<prog> Display the full path to compiler component <prog>.-print-multiarch Display the target's normalized GNU triplet, used asa component in the library path.-print-multi-directory Display the root directory for versions of libgcc.-print-multi-lib Display the mapping between command line options andmultiple library search directories.-print-multi-os-directory Display the relative path to OS libraries.-print-sysroot Display the target libraries directory.-print-sysroot-headers-suffix Display the sysroot suffix used to find headers.-Wa,<options> Pass comma-separated <options> on to the assembler.-Wp,<options> Pass comma-separated <options> on to the preprocessor.-Wl,<options> Pass comma-separated <options> on to the linker.-Xassembler <arg> Pass <arg> on to the assembler.-Xpreprocessor <arg> Pass <arg> on to the preprocessor.-Xlinker <arg> Pass <arg> on to the linker.-save-temps Do not delete intermediate files.-save-temps=<arg> Do not delete intermediate files.-no-canonical-prefixes Do not canonicalize paths when building relativeprefixes to other gcc components.-pipe Use pipes rather than intermediate files.-time Time the execution of each subprocess.-specs=<file> Override built-in specs with the contents of <file>.-std=<standard> Assume that the input sources are for <standard>.--sysroot=<directory> Use <directory> as the root directory for headersand libraries.-B <directory> Add <directory> to the compiler's search paths.-v Display the programs invoked by the compiler.-### Like -v but options quoted and commands not executed.-E Preprocess only; do not compile, assemble or link.-S Compile only; do not assemble or link.-c Compile and assemble, but do not link.-o <file> Place the output into <file>.-pie Create a dynamically linked position independentexecutable.-shared Create a shared library.-x <language> Specify the language of the following input files.Permissible languages include: c c++ assembler none'none' means revert to the default behavior ofguessing the language based on the file's extension.Options starting with -g, -f, -m, -O, -W, or --param are automaticallypassed on to the various sub-processes invoked by aarch64-none-elf-gcc. In order to passother options on to these processes the -W<letter> options must be used.For bug reporting instructions, please see:<https:///>.[root@centos7 arm]# gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gcc --versionaarch64-none-elf-gcc (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 10.3.1 20210621Copyright (C) 2020 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.[root@centos7 arm]#[root@centos7 step-08]# make[GCC] commands.o[GCC] kernel.o[GCC] shell.o[GCC] string.o[GCC] uart1.o[GCC] util.o[LD] kernel8.elf/root/arm/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-ld: /lib64/libc.so.6: version `GLIBC_2.27' not found (required by /root/arm/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-ld) make: *** [Makefile:43: kernel8.elf] Error 1[root@centos7 step-08]#换个操作系统root@ubuntu:~# uname -aLinux ubuntu 5.0.0-23-generic #24~18.04.1-Ubuntu SMP Mon Jul 2916:10:24 UTC 2019 aarch64 aarch64 aarch64 GNU/Linuxroot@ubuntu:~#Last login: Wed Mar 920:08:152022from192.168.116.24root@ubuntu:~# uname -aLinux ubuntu 5.0.0-23-generic #24~18.04.1-Ubuntu SMP Mon Jul 2916:10:24 UTC 2019 aarch64 aarch64 aarch64 GNU/Linuxroot@ubuntu:~# ldd --versionldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27Copyright (C) 2018 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.Written by Roland McGrath and Ulrich Drepper.root@ubuntu:~# whereis libc.so.6libc.so: /lib/aarch64-linux-gnu/libc.so.6 /usr/lib/aarch64-linux-gnu/libc.soroot@ubuntu:~# strings /lib/aarch64-linux-gnu/libc.so.6 | grep GLIBCGLIBC_2.17GLIBC_2.18GLIBC_2.22GLIBC_2.23GLIBC_2.24GLIBC_2.25GLIBC_2.26GLIBC_2.27GLIBC_PRIVATEGNU C Library (Ubuntu GLIBC 2.27-3ubuntu1.3) stable release version 2.27.root@ubuntu:~#root@ubuntu:~/arm/bare-metal-aarch64# lsREADME.md step-00 step-01 step-02 step-03 step-04 step-05 step-06 step-07 step-08root@ubuntu:~/arm/bare-metal-aarch64# cd step-08root@ubuntu:~/arm/bare-metal-aarch64/step-08# lsboot.o boot.S commands.c commands.o include kernel8.ld kernel.c kernel.o Makefile README.md shell.c shell.o string.c string.o uart1.c uart1.o util.c util.oroot@ubuntu:~/arm/bare-metal-aarch64/step-08# make[LD] kernel8.elf[OBJCOPY] kernel8.imgroot@ubuntu:~/arm/bare-metal-aarch64/step-08# cat Makefile# Relative path to the prefix where the compiler was installed.COMPILER_PREFIX = ~/arm/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf# Prefix to use before all binutils, gcc and gdb commands.BINROOT = ${COMPILER_PREFIX}/bin/aarch64-none-elf-# Variable used to control the printing of commands.# Printing is disabled by default (due to the "@").# To enable command printing run "make Q= ..." instead of "make ...".Q = @# Flags passed to GCC.GCC_FLAGS = \-ffreestanding \-Wall -Wextra -Werror -pedantic \-O0 \-I ./include \-mgeneral-regs-only# Flags passed to QEMU.QEMU_FLAGS = -M raspi3 -nographic -serial null -serial mon:stdio .PHONY: allall: kernel8.imgboot.o: boot.S@echo "[AS] $@"${Q}${BINROOT}as -c $< -o $@# All header files.C_HDR = $(wildcard include/*.h) $(wildcard include/bcm2837/*.h) %.o: %.c ${C_HDR}@echo "[GCC] $@"${Q}${BINROOT}gcc ${GCC_FLAGS} -c $< -o $@# All C source files, and corresponding object files.C_SRC = $(wildcard *.c)C_OBJ = $(C_SRC:.c=.o)kernel8.elf: kernel8.ld boot.o ${C_OBJ}@echo "[LD] $@"${Q}${BINROOT}ld -T $< -o $@ $(filter-out $<,$^)kernel8.img: kernel8.elf@echo "[OBJCOPY] $@"${Q}${BINROOT}objcopy -O binary $< $@.PHONY: runrun: kernel8.img@echo "[QEMU] running with $<"@echo "(Press Ctrl-A X to exit QEMU.)"${Q}qemu-system-aarch64 ${QEMU_FLAGS} -kernel $<.PHONY: run-gdbrun-gdb: kernel8.img@echo "[QEMU] running with $< (waiting for GDB)"@echo "(Press Ctrl-A X to exit QEMU.)"${Q}qemu-system-aarch64 ${QEMU_FLAGS} -s -S -kernel $< .PHONY: gdbgdb: kernel8.elf@echo "[GDB] running with $<"${Q}${BINROOT}gdb -ex "target remote :1234" $<.PHONY: cleanclean:@rm -f *.o@rm -f kernel8.elf@rm -f kernel8.imgroot@ubuntu:~/arm/bare-metal-aarch64/step-08# make run [QEMU] running with kernel8.img(Press Ctrl-A X to exit QEMU.)********************************************* Hello, World!! *********************************************Initial value of x1: 0x0000000000000000.Initial value of x2: 0x0000000000000000.Initial value of x3: 0x0000000000000000.Initial entry point: 0x0000000000080000.Initial exception level: EL2.Current exception level: EL1.Address of the DTB: n/aEntering the interactive mode.>> hisError: unknown command "his".Use command "help" to get a list of commands.> helpList of available commands:- "help": list the available commands.- "echo": print each of its arguments.- "hexdump": dump memory starting at ARG1 for ARG2 bytes.- "inc": increment the secret counter via un hypervisor call.- "get": get the value of the secret counter via un hypervisor call. > inc>root@ubuntu:~/arm/bare-metal-aarch64/step-08# make run [QEMU] running with kernel8.img(Press Ctrl-A X to exit QEMU.)********************************************* Hello, World!! *********************************************Initial value of x1: 0x0000000000000000.Initial value of x2: 0x0000000000000000.Initial value of x3: 0x0000000000000000.Initial entry point: 0x0000000000080000.Initial exception level: EL2.Current exception level: EL1.Address of the DTB: n/aEntering the interactive mode.>> hisError: unknown command "his".Use command "help" to get a list of commands.> helpList of available commands:- "help": list the available commands.- "echo": print each of its arguments.- "hexdump": dump memory starting at ARG1 for ARG2 bytes.- "inc": increment the secret counter via un hypervisor call.- "get": get the value of the secret counter via un hypervisor call. > inc> getThe secret counter has value 1>。

CentOS7实现无线网卡配置及连接

CentOS7实现无线网卡配置及连接

CentOS7实现⽆线⽹卡配置及连接安装配置最近⽤到产品⽆线功能模块⾃动化⽆线连接测试,这次做⼀个环境部署配置总结,在centos7.7系统内核版本3.10,使⽤的是RTL8812AU⽆线芯⽚⽹卡,Realtek官⽅有提供Linux驱动没法编译,国外⼤佬做了⼀个可以⽤于3.1内核的改版驱动,需⽹上下载:rtl8812au.zip驱动包。

使⽤make、make install命令编译安装,安装完后最好reboot⼀下,如果在编译过程中出现问题,⼀般来说都是依赖没装好,尝试⽤以下命令解决:yum update (更新yum软件仓库)yum install gcc (安装gcc)安装完后,查看内核是否有加载的8812au模块:[root@Server ~]# lsmod | grep 88128812au 1011830 0不⽀持iw命令,例如输⼊iw dev会显⽰“nl80211 not found.”,并不影响使⽤。

使⽤ip link命令查看⽹卡设备名,可见下图ens35u1就是⽆线⽹卡设备名。

启动⽆线⽹卡:ifconfig ens35u1 up设置WIFI热点:⾸先如果还没安装wpa_supplicant的话,请先运⾏yum install wpa_supplicant然后修改配置⽂件:# vim /etc//wpa_supplicant/wpa_supplicant.confctrl_interface=/var/run/wpa_supplicant/update_config=1device_name=RTL8192CUmanufacturer=Realtekmodel_name=RTW_STAmodel_number=WLAN_CUserial_number=12345device_type=1-0050F204-1os_version=01020300config_methods=virtual_display virtual_push_button keypad以上内容就是添加到配置⽂件⾥。

《Linux网络操作系统项目教程(RHEL7.4 CentOS 7.4)(第3版))》习题及答案

《Linux网络操作系统项目教程(RHEL7.4  CentOS 7.4)(第3版))》习题及答案

《Linux网络操作系统项目教程(RHEL7、4/CentOS 7、4)(第3版)》课后习题答案1、11练习题一、填空题1.GNU得含义就是。

2。

Linux一般有3个主要部分:、、。

3。

目前被称为纯种得UNIX指得就就是以及这两套操作系统。

4.Linux就是基于得软件模式进行发布得,它就是GNU项目制定得通用公共许可证,英文就是。

5.史托曼成立了自由软件基金会,它得英文就是.6.POSIX就是得缩写,重点在规范核心与应用程序之间得接口,这就是由美国电气与电子工程师学会(IEEE)所发布得一项标准.7.当前得Linux常见得应用可分为与两个方面。

8.Linux得版本分为与两种。

9。

安装Linux最少需要两个分区,分别就是。

101、一个自由软件组织)2、内核(kernel)、命令解释层(Shell或其她操作环境)、实用工具3、System VBSD4、Copyleft(无版权)General PublicLicense,GPL)5、FSF,FreeSoftware Foundation6、便携式操作系统接口(Portable Operating System Interface)7、企业应用个人应用8、内核版本发行版本9、swap交换分区/(根)分区10、root二、选择题1.Linux最早就是由计算机爱好者()开发得。

A.Richard Petersen ﻩﻩB.Linus TorvaldsﻩC。

Rob Pick ﻩﻩﻩD.Linux Sarwar2。

下列中()就是自由软件。

A。

Windows XPﻩB。

UNIX C.Linux D.Windows20083。

下列中( )不就是Linux得特点。

A.多任务ﻩB.单用户C。

设备独立性D.开放性4.Linux得内核版本2、3、20就是( )得版本。

A。

不稳定B。

稳定得ﻩC.第三次修订ﻩﻩD.第二次修订5.Linux安装过程中得硬盘分区工具就是()。

A.PQmagicﻩﻩB.FDISKﻩﻩC。

CentOS7编译和安装GCC7.5

CentOS7编译和安装GCC7.5

CentOS7编译和安装GCC7.5CentOS7编译和安装GCC7.5⼀、环境介绍:CentOS7虚拟机连上了互联⽹(为什么要强调这点呢,因为CentOS7每次进⼊系统,都需要⼿动点击右上⾓的Connect,才能连上互联⽹。

在⾮联⽹情况下,会出现各种问题,影响我们的判断和安装)⼆、为什么是GCC7.5CentOS7 ⾃带的 gcc/g++ 版本是 4.8,如果没有安装,可以通过 yum 命令安装。

由于 gcc/g++ 4.8 完全⽀持 C++ 11,⽀持部分 C++ 14,不⽀持 C++ 17,⽽完全⽀持 C++ 17 的是 g++ 7 及以上版本:个⼈不太建议安装GCC8.X,太新的编译器,所需要的依赖包、各种环境都需要最新版本,安装过程中会出现很多问题。

⽽且还不⼀定那么稳定。

本着够⽤就好的原则,GCC7.5完全⽀持C++17,是最理想的选择。

若⼲参考链接:三、安装步骤3.1更新系统以及安装若⼲相关的包(包括gcc gcc-c++)在root权限下⾯进⾏这些操作sudo yum -y updatesudo yum -y install bzip2wget gcc gcc-c++ gmp-devel mpfr-devel libmpc-devel makesudo yum -y install zlibsudo yum -y install zlib-devel3.2下载GCC7.5的⼯程⽂件(下⾯的步骤,建议在⾮root权限下操作)wget https:///gnu/gcc/gcc-7.5.0/gcc-7.5.0.tar.gztar -zxvf gcc-7.5.0.tar.gzcd gcc-7.5.03.3安装若⼲gcc的依赖包./contrib/download_prerequisitesmkdir gcc-build-7.5cd gcc-build-7.53.4⽣成Makefile⽂件(下⾯这个是⼀⾏,请直接复制粘贴)../configure --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=gnu3.5编译(这个编译⽐较耗时)make -j43.6安装(需要root权限)make install3.7查看gcc版本gcc -v3.8动态库 libstdc++.so.6 的更新(在root权限下进⾏下⾯的操作)检查动态库:strings /usr/lib64/libstdc++.so.6 | grep GLIBC从输出可以看出,gcc的动态库还是旧版本的。

Centos8安装gcc的方法

Centos8安装gcc的方法

Centos8安装gcc的⽅法GCCGCC是GNU编译器套件,是由GNU开发的编程语⾔的编译器。

GNU编译器套件包括C、C++、Objective-C、Fortran、Java、Ada和Go语⾔及这些语⾔的库,使⽤gcc编译程序时,编译过程可以为4个阶段:预处理(Pre-Processing)、编译(Compiling)、汇编(Assembling)、链接(Linking)由于 Linux 操作系统的⾃由开源,在其基础上衍⽣出了很多不同的Linux操作系统,如CentOS、Ubuntu、Debian等,这些Linux发⾏版中,⼤多数都默认装有GCC编译器,但是在CentOS8中并没有安装,这就需要⾃⼰来安装了下⾯介绍在线安装、离线安装及版本升级⽅法,安装系统是CentOS 8.3,其它版本可能略有不同在线安装是⼀种极其简单的“傻⽠式”安装⽅法,但是其默认根据当前系统版本所对应的gcc进⾏安装,⽽⾮选择最新版gcc进⾏安装1. 确认当前系统是否已安装gcc,执⾏以下命令rpm -q gcc#或者输⼊查看gcc版本的命令gcc -v2. 使⽤命令安装dnf install gcc gcc-c++ -y3. 等待安装结束后再次输⼊查看gcc版本的命令,出现gcc版本信息就说明安装成功啦rpm -q gcc#输⼊查看gcc版本的命令gcc --versongcc -vg++ -v将gcc-8.3升级到gcc10.2,若未安装gcc,不能使⽤该⽅法直接安装gcc,没有旧版本的gcc,编译时会失败的,会报错configure: error: no acceptable C compiler found in $PATH1. 下载gcc-10.2的安装包,若下载失败可以通过国内镜像站下载,在华为、阿⾥、清华等镜像站搜索GNU,选择需要的版本wget https:///pub/gcc/releases/gcc-10.2.0/gcc-10.2.0.tar.gz2. 解压并进⼊⽬录tar -zxf gcc-10.2.0.tar.gzcd gcc-10.2.03. 执⾏以下命令,下载安装gcc的依赖包,由于⽹络原因,下载时间可能会有点久,请耐⼼等待./contrib/download_prerequisites4. 由于gcc编译器⽀持多种语⾔的编译,⽽实际情况中可能只需要编译 1~2 种编程语⾔,因此需要对其进⾏必要的配置。

详解Linux(centos7)下安装OpenSSL安装图文方法

详解Linux(centos7)下安装OpenSSL安装图文方法

详解Linux(centos7)下安装OpenSSL安装图⽂⽅法OpenSSL是⼀个开源的ssl技术,由于我需要使⽤php相关功能,需要获取https的⽂件所以必须安装这个东西了,下⾯我整理了两种关于OpenSSL安装配置⽅法。

安装环境:操作系统:CentOs7安静OpenSSL Version:openssl-1.0.2j.tar.gz1、将下载的压缩包放在根⽬录,2、在⽂件夹下解压缩,命令:tar -xzf openssl-1.0.2j.tar.gz,得到openssl-1.0.2j⽂件夹3、进⼊解压的⽬录:cd openssl-1.0.2j4、设定Openssl 安装,( --prefix )参数为欲安装之⽬录,也就是安装后的档案会出现在该⽬录下:执⾏命令: ./config --prefix=/usr/local/openssl5、执⾏命令./config -t6.执⾏make,编译Openssl这⾥如果出现如下错误make[1]: gcc: Command not found⽣⽓上⽹查才发现我安装的CentOS7中没有GCC编译器保证系统⽹络畅通以后,执⾏命令 yum -y install gcc 安装GCC(注意,⼀定要忘了顺畅,不然安装不了)7、安装 Openssl:make install8、执⾏以下命令[root@localhost /]# cd /usr/local[root@localhost local]# ldd /usr/local/openssl/bin/openssl会出现类似如下信息:9、查看路径...]# which openssl查看版本...]# openssl version卸载旧版本 OpenSSL的⽅法apt-get purge opensslrm -rf /etc/ssl #删除配置⽂件以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

centos7下gcc离线安装

centos7下gcc离线安装

centos7下gcc离线安装1、在centos安装镜像⽂件ios中的Packages⽂件夹中需找安装⽂件:把需要的⽂件直接复制出来就⾏。

这⾥提醒的⼀点是,如果⽤命令⾏进⼊该⽂件夹,因为⽂件路径带空格,所以需要加上双引号:[root@cm1 ~]# cd /run/media/root/CentOS 7 x86_64/Packagesbash: cd: /run/media/root/CentOS: 没有那个⽂件或⽬录[root@cm1 ~]# cd /run/media/root/"CentOS 7 x86_64"/Package进⼊Packages⽂件夹之后,把如下gcc、gcc c++ 以及他们的依赖包复制出来:按照依赖关系,依次安装即可:[root@cm1 gcc]# lscpp-4.8.5-28.el7.x86_64.rpm glibc-headers-2.17-222.el7.x86_64.rpmgcc-4.8.5-28.el7.x86_64.rpm kernel-headers-3.10.0-862.el7.x86_64.rpmglibc-devel-2.17-222.el7.x86_64.rpm libgomp-4.8.5-28.el7.x86_64.rpm[root@cm1 gcc]# rpm -ivh cpp-4.8.5-28.el7.x86_64.rpm警告:cpp-4.8.5-28.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY准备中... ################################# [100%]软件包 cpp-4.8.5-28.el7.x86_64 已经安装[root@cm1 gcc]# rpm -ivh kernel-headers-3.10.0-862.el7.x86_64.rpm警告:kernel-headers-3.10.0-862.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY准备中... ################################# [100%]正在升级/安装...1:kernel-headers-3.10.0-862.el7 ################################# [100%][root@cm1 gcc]# rpm -ivh glibc-headers-2.17-222.el7.x86_64.rpm警告:glibc-headers-2.17-222.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY准备中... ################################# [100%]正在升级/安装...1:glibc-headers-2.17-222.el7 ################################# [100%][root@cm1 gcc]# rpm -ivh glibc-devel-2.17-222.el7.x86_64.rpm警告:glibc-devel-2.17-222.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY准备中... ################################# [100%]正在升级/安装...1:glibc-devel-2.17-222.el7 ################################# [100%][root@cm1 gcc]# rpm -ivh libgomp-4.8.5-28.el7.x86_64.rpm警告:libgomp-4.8.5-28.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY准备中... ################################# [100%]软件包 libgomp-4.8.5-28.el7.x86_64 已经安装[root@cm1 gcc]# rpm -ivh gcc-4.8.5-28.el7.x86_64.rpm警告:gcc-4.8.5-28.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY准备中... ################################# [100%][root@cm1 ~]# cd gcc[root@cm1 gcc]# rpm -ivh gcc-c++-4.8.5-28.el7.x86_64.rpm警告:gcc-c++-4.8.5-28.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY错误:依赖检测失败:libstdc++-devel = 4.8.5-28.el7 被 gcc-c++-4.8.5-28.el7.x86_64 需要[root@cm1 gcc]# rpm -ivh libstdc++-devel-4.8.5-28.el7.x86_64.rpm警告:libstdc++-devel-4.8.5-28.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY准备中... ################################# [100%]正在升级/安装...1:libstdc++-devel-4.8.5-28.el7 ################################# [100%][root@cm1 gcc]# rpm -ivh gcc-c++-4.8.5-28.el7.x86_64.rpm警告:gcc-c++-4.8.5-28.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY准备中... ################################# [100%]正在升级/安装...1:gcc-c++-4.8.5-28.el7 ################################# [100%][root@cm1 gcc]#正在升级/安装...1:gcc-4.8.5-28.el7 ################################# [100%][root@cm1 gcc]#make过程报错:xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个⽂件或⽬录:安装expat-devel/usr/local/openssl/include/openssl/rsa.h:62:26: 致命错误:openssl/asn1.h:没有那个⽂件或⽬录:安装openssl-devel 安装⽂件都可以⽤ios那个Packages⽬录中找。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

centos7 编译gcc -回复
如何在CentOS 7上编译GCC
CentOS 7是一种广泛使用的Linux发行版之一,常用于服务器和开发环境。

在使用CentOS 7进行编程工作时,有时我们需要使用最新版本的GCC编译器来编译和运行我们的程序。

本文将逐步介绍在CentOS 7上编译和安装GCC的过程,帮助读者完成这一任务。

步骤1:安装必要的依赖项
在开始编译GCC之前,我们首先需要确保系统上已安装了一些必要的依赖项。

打开终端并使用以下命令:
sudo yum install -y wget gcc-c++ glibc-devel
该命令将使用yum包管理器安装wget(用于下载源代码),gcc-c++(用于编译源代码)和glibc-devel(用于系统库的开发包)。

步骤2:下载GCC源代码
在终端执行以下命令,将下载最新版本的GCC源代码:
wget
该命令将使用wget工具从GNU网站下载GCC的源代码包。

步骤3:解压源代码
完成下载后,使用以下命令解压源代码包:
tar -xf gcc-10.2.0.tar.gz
这将解压缩GCC源代码到当前目录。

步骤4:创建构建目录
为了保持源代码和构建文件的分离,我们将在源代码目录之外创建一个构建目录。

在终端执行以下命令:
mkdir build-gcc
这将创建一个名为"build-gcc"的目录。

步骤5:配置编译选项
在终端的当前目录更改为构建目录:
cd build-gcc
然后,运行以下命令以配置GCC的编译选项:
../gcc-10.2.0/configure prefix=/usr/local/gcc-10.2.0
enable-languages=c,c++
这将为GCC设置一些选项,如安装目录和编译的语言。

步骤6:编译和安装GCC
通过以下命令开始GCC的编译过程:
make -j4
这将开始GCC的编译过程。

请确保在"make"命令中使用"-j"选项并指定CPU核心数,以便加速编译过程。

在本例中,我们使用了"4",但您可以根据自己的系统配置进行调整。

完成编译后,通过以下命令将GCC安装到系统中:
sudo make install
请注意,这将需要管理员权限来安装GCC。

步骤7:设置环境变量
为了让系统知道新安装的GCC的位置,我们需要将其添加到环境变量中。

打开终端,并使用以下命令编辑".bashrc"文件:
nano ~/.bashrc
在打开的文件中添加以下行,并保存文件:
export PATH=PATH:/usr/local/gcc-10.2.0/bin
然后按下"Ctrl + X"键,选择"Y"保存文件,然后按下"Enter"键退出编辑器。

步骤8:生效环境变量
在编辑.bashrc文件后,我们需要在当前终端会话中使环境变量生效。


行以下命令:
source ~/.bashrc
这将重新加载.bashrc文件并使环境变量生效。

步骤9:验证GCC安装
最后,我们可以通过在终端运行以下命令来验证GCC是否成功安装:gcc version
如果一切顺利,您将看到GCC的版本信息。

总结:
在本文中,我们逐步说明了在CentOS 7上编译和安装GCC的过程。

通过按照这些步骤进行操作,读者将能够成功地在CentOS 7系统上编译和安装最新版本的GCC编译器。

GCC是一个非常强大和广泛使用的编译器,具有广泛的语言支持和许多功能,为开发人员提供了一个强大的工具来编写和优化他们的代码。

相关文档
最新文档