- Installing GCC
- Building GCC
- Support libraries
- Configuration
- jeetsukumaran / build-gcc.sh
- This comment has been minimized.
- skaronn commented Apr 23, 2015
- This comment has been minimized.
- jithinjk commented Feb 15, 2017
- This comment has been minimized.
- bhardwajhp commented Apr 25, 2017
- This comment has been minimized.
- EvilSupahFly commented Aug 29, 2017
- This comment has been minimized.
- gauravchak commented Dec 19, 2018
- nchaigne / build-gcc-9.2.0-on-centos7.md
- Пакет: gcc (4:9.3.0-1ubuntu2)
- Ссылки для gcc
- Ресурсы Ubuntu:
- Сопровождающий:
- Original Maintainers (usually from Debian):
- Подобные пакеты:
- GNU C compiler
- Другие пакеты, относящиеся к gcc
- Загрузка gcc
Installing GCC
This page is intended to offer guidance to avoid some common problems when installing GCC, the official installation docs are in the Installing GCC section of the main GCC documentation. N.B. those installation docs refer to the development trunk, the installation instructions for released versions are included in the release sources.
For most people the easiest way to install GCC is to install a package made for your operating system. The GCC project does not provide pre-built binaries of GCC, only source code, but all GNU/Linux distributions include packages for GCC. The BSD-based systems include GCC in their ports collections. For other operating systems the Installing GCC: Binaries page lists some third-party sources of GCC binaries.
If you cannot find suitable binaries for your system, or you need a newer version than is available, you will need to build GCC from source in order to install it.
Building GCC
Many people rush into trying to build GCC without reading the installation docs properly and make one or more of these common mistakes:
do not run ./configure from within the source directory, this is not supported. You need to run configure from outside the source directory, in a separate directory created for the build (this is a FAQ)
if GCC links dynamically to the GMP, MPFR or MPC support libraries then the relevant shared libraries must be in the dynamic linker’s path, both when building gcc and when using the installed compiler (this is also a FAQ)
Support libraries
See Installing GCC: Prequisites for the software required to build GCC. If you do not have the GMP, MPFR and MPC support libraries already installed as part of your operating system then there are two simple ways to proceed, and one difficult, error-prone way. For some reason most people choose the difficult way. The easy ways are:
If it provides sufficiently recent versions, use your OS package management system to install the support libraries in standard system locations. For Debian-based systems, including Ubuntu, you should install the packages libgmp-dev, libmpfr-dev and libmpc-dev. For RPM-based systems, including Fedora and SUSE, you should install gmp-devel, mpfr-devel and libmpc-devel (or mpc-devel on SUSE) packages. The packages will install the libraries and headers in standard system directories so they can be found automatically when building GCC.
Alternatively, after extracting the GCC source archive, simply run the ./contrib/download_prerequisites script in the GCC source directory. That will download the support libraries and create symlinks, causing them to be built automatically as part of the GCC build process. Set GRAPHITE_LOOP_OPT=no in the script if you want to build GCC without ISL, which is only needed for the optional Graphite loop optimizations.
The difficult way, which is not recommended, is to download the sources for GMP, MPFR and MPC, then configure and install each of them in non-standard locations, then configure GCC with —with-gmp=/some/silly/path/gmp —with-mpfr=/some/silly/path/mpfr —with-mpc=/some/silly/path/mpc, then be forced to set LD_LIBRARY_PATH=/some/silly/path/gmp:/some/silly/path/mpfr:/some/silly/path/mpc/lib in your environment forever. This is silly and causes major problems for anyone who doesn’t understand how dynamic linkers find libraries at runtime. Do not do this. If building GCC fails when using any of the —with-gmp or —with-mpfr or —with-mpc options then you probably shouldn’t be using them.
Configuration
See Installing GCC: Configuration for the full documentation. A major benefit of running srcdir /configure from outside the source directory (instead of running ./configure) is that the source directory will not be modified in any way, so if your build fails or you want to re-configure and build again, you simply delete everything in the objdir and start again.
For example, configuring and building GCC 4.6.2 (with support for C, C++, Fortran and Go) should be as simple as:
The make step takes a long time. If your computer has multiple processors or cores you can speed it up by building in parallel using make -j 2 (or a higher number for more parallelism).
If your build fails and your configure command has lots of complicated options you should try removing options and keep it simple. Do not add lots of configure options you don’t understand, they might be the reason your build fails.
None: InstallingGCC (последним исправлял пользователь JonathanWakely 2017-07-20 19:47:08)
Источник
jeetsukumaran / build-gcc.sh
#! /bin/bash |
GCC_VERSION= » 5.2.0 « |
WORKDIR= » $HOME /src/ « |
INSTALLDIR= » /platform « |
# # NOTE: XCode must be installed (through App Store) and the following run to install command-line tools. |
# # THIS IS IMPORTANT! Among other things, it creates ‘/usr/include’ and installs the system header files. |
# xcode-select —install |
# get the source code |
cd $WORKDIR |
wget http://www.netgull.com/gcc/releases/gcc- $ |
tar -xf gcc- $ |
# download the prerequisites |
cd gcc- $ |
./contrib/download_prerequisites |
# create the build directory |
cd .. |
mkdir gcc-build |
cd gcc-build |
# build |
../gcc- $ |
—prefix= $ |
—enable-shared \ |
—enable-threads=posix \ |
—enable-__cxa_atexit \ |
—enable-clocale=gnu \ |
—enable-languages=all \ |
&& make \ |
&& make install |
# Notes |
# |
# —enable-shared —enable-threads=posix —enable-__cxa_atexit: |
# These parameters are required to build the C++ libraries to published standards. |
# |
# —enable-clocale=gnu: |
# This parameter is a failsafe for incomplete locale data. |
# |
# —disable-multilib: |
# This parameter ensures that files are created for the specific |
# architecture of your computer. |
# This will disable building 32-bit support on 64-bit systems where the |
# 32 bit version of libc is not installed and you do not want to go |
# through the trouble of building it. Diagnosis: «Compiler build fails |
# with fatal error: gnu/stubs-32.h: No such file or directory» |
# |
# —with-system-zlib: |
# Uses the system zlib instead of the bundled one. zlib is used for |
# compressing and uncompressing GCC’s intermediate language in LTO (Link |
# Time Optimization) object files. |
# |
# —enable-languages=all |
# —enable-languages=c,c++,fortran,go,objc,obj-c++: |
# This command identifies which languages to build. You may modify this |
# command to remove undesired language |
This comment has been minimized.
Copy link Quote reply
skaronn commented Apr 23, 2015
Does your script work on windows OS ?
This comment has been minimized.
Copy link Quote reply
jithinjk commented Feb 15, 2017
[root@localhost /home/admin/gcc-6.3.0]# ./contrib/download_prerequisites
./contrib/download_prerequisites: line 37: wget: command not found
[root@localhost /home/admin/wget-1.19]# ./configure
When I try to install wget, I get the following error:
configure: configuring for GNU Wget 1.19
checking for a BSD-compatible install. /usr/bin/install -c
checking whether build environment is sane. yes
checking for a thread-safe mkdir -p. /bin/mkdir -p
checking for gawk. gawk
checking whether make sets $(MAKE). yes
checking whether make supports nested variables. yes
checking build system type. x86_64-pc-linux-gnu
checking host system type. x86_64-pc-linux-gnu
checking whether make supports nested variables. (cached) yes
checking for gcc. no
checking for cc. no
checking for cl.exe. no
configure: error: in /home/admin/test/wget-1.19′: configure: error: no acceptable C compiler found in $PATH See config.log’ for more details
This comment has been minimized.
Copy link Quote reply
bhardwajhp commented Apr 25, 2017
@jithinjk from the log it looks like you need to install «wget» as well as «gcc» on the machine.
This comment has been minimized.
Copy link Quote reply
EvilSupahFly commented Aug 29, 2017
Nice utility, but GCC has started using .tar.gz now for releases instead of .tar.bz2 beginning with 6.4.0 so if the version number is changed (7.2.0 for example), the script will fail if the archive is not changed as well.
This comment has been minimized.
Copy link Quote reply
gauravchak commented Dec 19, 2018
I followed the steps. However, I am stuck with an error related to -no-pie not being supported by the old g++ I was using to build this new one. Please help.
The configure command I used to build gcc 8.2:
Источник
nchaigne / build-gcc-9.2.0-on-centos7.md
Building GCC 9.2.0 on CentOS 7
CentOS 7 distribution (as well as RHEL 7) ships with a somewhat outdated version of the GCC compiler (4.8.5 on CentOS 7.5), which may not be suitable to your compilation requirements. For example, C11 — which supersedes C99 — is fully supported only starting from GCC 4.9).
Additionally, recent versions of GCC (GCC6, GCC7, GCC8, GCC9) come with improvements which help detect issues at build time and offer suggestions on how to fix them. Sometimes, these are even actually helpful!
This note describes how to build the latest GCC (9.2.0 as of October 2019) from sources on CentOS 7. This should be applicable as is on RHEL 7. For other Linux distributions, adapt as needed.
While this is not overly complicated, building GCC takes quite some time. So you might want to plan to do something else while it builds. a coffee break just won’t make it.
Required support libraries, listed hereafter, can be downloaded automatically using script download_prerequisites included in the GCC archive. It’s convenient, so we’ll do that.
Build and install gcc
cd /home/build
GCC_VERSION=9.2.0
wget https://ftp.gnu.org/gnu/gcc/gcc-$/gcc-$ .tar.gz
tar xzvf gcc-$.tar.gz
mkdir obj.gcc-$
cd gcc-$
./contrib/download_prerequisites
cd ../obj.gcc-$
../gcc-$/configure —disable-multilib —enable-languages=c,c++
make -j $(nproc)
make install
- If you have several processors available, you can benefit from a parallel build. For example, make -j 6 will use 6 CPUs. (You might want to save a few for yourself, so you can do things on your server while gcc builds.)
- Make sure you have enough space in /home/build (or whatever location you choose). You will need
1 GB for gcc sources,
6 GB for the build). Be prepared.
Источник
Пакет: gcc (4:9.3.0-1ubuntu2)
Ссылки для gcc
Ресурсы Ubuntu:
Сопровождающий:
Please consider filing a bug or asking a question via Launchpad before contacting the maintainer directly.
Original Maintainers (usually from Debian):
- Debian GCC Maintainers (Почтовый архив)
- Matthias Klose
It should generally not be necessary for users to contact the original maintainer.
Подобные пакеты:
GNU C compiler
Другие пакеты, относящиеся к gcc
|
|
|
|
- dep: cpp (= 4:9.3.0-1ubuntu2) GNU C preprocessor (cpp)
- dep: gcc-9 (>= 9.3.0-3
) GNU C compiler
- rec: libc6-dev GNU C Library: Development Libraries and Header Files или libc-dev виртуальный пакет, предоставляемый libc6-dev
- sug: autoconf automatic configure script builder
- sug: automake Tool for generating GNU Standards-compliant Makefiles
- sug: bison YACC-compatible parser generator
- sug: flex fast lexical analyzer generator
- sug: gcc-doc Documentation for the GNU C compilers (gcc, gobjc, g++)
- sug: gcc-multilib GNU C compiler (multilib files)
- sug: gdb GNU Debugger
- sug: libtool Generic library support script
- sug: make utility for directing compilation
- sug: manpages-dev Manual pages about using GNU/Linux for development
Загрузка gcc
Архитектура | Размер пакета | В установленном виде | Файлы |
---|---|---|---|
amd64 | 5,1 Кб | 50,0 Кб | [список файлов] |
arm64 | 5,1 Кб | 50,0 Кб | [список файлов] |
armhf | 5,1 Кб | 50,0 Кб | [список файлов] |
i386 | 5,1 Кб | 64,0 Кб | [список файлов] |
ppc64el | 5,1 Кб | 50,0 Кб | [список файлов] |
s390x | 5,1 Кб | 50,0 Кб | [список файлов] |
This page is also available in the following languages:
Авторские права © 2021 Canonical Ltd.; См. условия лицензии. Ubuntu это торговый знак компании Canonical Ltd. Об этом сайте.
Источник