Install cpp on linux

Installing the GNU C compiler and GNU C++ compiler

To install the gcc and g++ compilers, you will need the build-essential package. This will also install GNU make.

build-essential contains a list of packages which are essential for building Ubuntu packages including gcc compiler, make and other required tools.

$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install build-essential $ gcc -v $ make -v

Now, you should able to compile software using C / C++ compilers.

To install the manpages for c and c++ development, install the manpages-dev package.

Installing the GNU Java compiler

Note that GNU’s Java compiler is not the same as the one developed and distributed by Sun Microsystems, and will not provide Java to the firefox browser. For that, please see Java. To install gcj, the GNU Java compiler, install the following package: gcj.

To install the GNU Java bytecode interpreter, you need the gij package.

To have gcj compile to executables, install libgcj6-dev (otherwise an error during compilation occurs: libgcj.spec: No such file or directory). Use synaptic to install libgcj6-dev.

Installing the GNU Fortran compilers

To install the GNU Fortran 77 compiler — g77, you need the g77 package.

To install the GNU Fortran 95 compiler — gfortran, the package is: gfortran.

Installing the GNU autotools

To install autoconf and automake, you need the autoconf and automake packages.

Apt-get will tell you to explicitly choose a version of automake. If, for example, you decide to use automake1.9, you need to specify the version, such as the automake1.9 package.

32-bit Builds on AMD64

The GNU compilers have options that allow them to create 32-bit object and executable files on 64-bit operating systems, and vica versa. The critical options are -m32 (to build 32-bit) and -m64 (to build 64-bit).

These options will be present when you install the compiler of your choice. However, they won’t actually work unless you install several additional packages.

The first thing you will need is the multilib package for the compiler you are using. For example, to add multilib support to the default version of g++ (4.1 in gutsy), you would install . For 4.2, you would need .

The multilib packages are compiler runtime packages. Now, you need 32-bit (or 64-bit) versions of whatever libraries you need to link your application program. 64-bit packages have names that start with lib64. Install these on 32-bit systems to support 64-bit builds. 32-bit packages have names that start with lib32. Install these on 64-bit systems to support 32-bit builds. Whatever else you are doing, you will probably need . If you are using g++, you will need .

Читайте также:  Linux запретить локальный вход

Installing the Intel Compiler Suite Professional Edition 10.x

  1. gcc, build-essential, libc6-dev (see above)
  2. ia32-libs, g++-multilib, and libc6-dev-i386 (for 64-bit systems)
  3. 32-bit packages starting with lib32 (for 64-bit systems)
  4. alien and rpm for installing the RPM packages that Intel distributes.
  5. libstdc++5 and libstdc++5-3.3-dev for good measure because Intel’s builds depend on these runtimes.

before you attempt installing the Intel Compiler Suite.

Get the License Number and Extract to a path without spaces

Ensure that you have obtained the license number for your installation and extracted the downloaded installation archive into a path that does not contain any spaces. This last statement is utterly important. The installer script that comes with the package has a bug that does not allow you to install the compiler suite if you have any spaces in the installer script path.

On 64-bit systems you may also need to issue these commands

# cd /usr/lib32 # ln -s libpthread.so libpthread.so.0 # ln -s libm.so libm.so.6 # ln -s libc.so libc.so.6 # ln -s libdl.so libdl.so.2

because the chklic_32_64 license checking utility from Intel dynamically links to these libraries.

Once you’re done preparing to install the compiler suite, it’s time to go to the installer directory and install the compiler (be sure to also read through accompanying documentation; e.g., README, INSTALL.txt):

Run the Installation Script

$ cd /home/user/intel_compiler_suite $ sudo ./install.sh . Follow the wizard as it guides you through the installation process.

After installing the compiler, you need to tell your shell the location of these executables by adding their parent paths to the PATH environment variable.

Edit /etc/bash.bashrc to add the installation path to the PATH environment variable

export PATH=/opt/intel/cc/10.1.012/bin:/opt/intel/idb/10.1.012/bin:$

Where 10.1.012 is the version of the compiler suite installed.

Installing the X11 development compilers

Install script for X11 development libs

$ sudo apt-get -y install libx11-dev

InstallingCompilers (последним исправлял пользователь cable-31-58 2012-08-10 10:18:50)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

Источник

How to Install GCC(C and C++ Compiler) on Ubuntu 20.04 LTS

How to Install GCC(C and C++ Compiler) on Ubuntu 20.04 LTS 1

In this article, we will see the steps to install GCC on Ubuntu 20.04 LTS. GCC or GNU Compiler Collection is a free and open source set of mostly C and C++ Compilers which are used to compile C and C++ based programs. It is widely used by programmers and developers across the world to compile their complex programs using different features and options provided by the gcc. Furthermore, it can also compile programs written in Fortran, Ada, GO and D programming language. It is very easy to install in almost all the famous linux distributions. Here we will see the steps to install GCC on Ubuntu 20.04 LTS based Systems.

Читайте также:  Узнать свободен ли порт linux

How to Install GCC(C and C++ Compiler) on Ubuntu 20.04 LTS 2

How to Install GCC(C and C++ Compiler) on Ubuntu 20.04 LTS

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get utility available in your Server.

Step 2: Update Your Server

Before going through the steps to install gcc on Ubuntu, it is highly recommended to update and upgrade all the installed packages to the latest version using sudo apt update && sudo apt upgrade command as shown below.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade [sudo] password for cyberithub: Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Hit:2 http://in.archive.ubuntu.com/ubuntu focal InRelease Get:3 https://dl.google.com/linux/chrome/deb stable InRelease [1,811 B] Get:4 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Get:5 https://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1,075 B] Get:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [1,950 kB] Get:7 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB] Get:8 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2,335 kB] Get:9 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [775 kB] Get:10 http://in.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [403 kB] Get:11 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [274 kB] Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [16.2 kB] Get:13 http://in.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [1,565 kB] .

Step 3: Install GCC

In the next step, you can install gcc by using sudo apt install gcc command as shown below. This will download and install the package along with all its dependencies from Ubuntu repo.

cyberithub@ubuntu:~$ sudo apt install gcc [sudo] password for cyberithub: Reading package lists. Done Building dependency tree Reading state information. Done The following packages were automatically installed and are no longer required: libfwupdplugin1 libllvm11 libxmlb1 Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu gcc-9 libasan5 libbinutils libc-dev-bin libc6-dev libcrypt-dev libctf-nobfd0 libctf0 libgcc-9-dev libitm1 liblsan0 libquadmath0 libtsan0 libubsan1 linux-libc-dev manpages-dev Suggested packages: binutils-doc gcc-multilib make autoconf automake libtool flex bison gcc-doc gcc-9-multilib gcc-9-doc gcc-9-locales glibc-doc The following NEW packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu gcc gcc-9 libasan5 libbinutils libc-dev-bin libc6-dev libcrypt-dev libctf-nobfd0 libctf0 libgcc-9-dev libitm1 liblsan0 libquadmath0 libtsan0 libubsan1 linux-libc-dev manpages-dev 0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded. Need to get 25.7 MB of archives. After this operation, 120 MB of additional disk space will be used. Do you want to continue? [Y/n] y .

Step 4: Verify Installation

After successful installation, you can verify the installed files path by using dpkg -L gcc command as shown below. You can check more about dpkg command on 21+ Practical dpkg Command Examples for Linux Beginners article.

cyberithub@ubuntu:~$ dpkg -L gcc /. /usr /usr/bin /usr/bin/c89-gcc /usr/bin/c99-gcc /usr/lib /usr/lib/bfd-plugins /usr/share /usr/share/doc /usr/share/doc/cpp /usr/share/man /usr/share/man/man1 /usr/share/man/man1/c89-gcc.1.gz /usr/share/man/man1/c99-gcc.1.gz /usr/bin/gcc /usr/bin/gcc-ar /usr/bin/gcc-nm /usr/bin/gcc-ranlib /usr/bin/gcov /usr/bin/gcov-dump .

Step 5: Check Version

You can also check the current installed version by using gcc —version command as shown below.

cyberithub@ubuntu:~$ gcc --version gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Step 6: Write a Sample Program

Now that gcc compiler is installed, it is time to write a sample C program to test the compiler. Here we are using below simple program to show a quick demo. This program will simply display a message Hi, This is from CyberITHub !! on the output.

cyberithub@ubuntu:~$ nano example.c #include int main() < printf("Hi, This is from CyberITHub !!\n"); >

To compile the above program, you can use gcc -o example example.c command as shown below.

cyberithub@ubuntu:~$ gcc -o example example.c

Then you can run the program by using ./example as shown below.

cyberithub@ubuntu:~$ ./example Hi, This is from CyberITHub !!

Источник

Читайте также:  Символьная ссылка на папку linux

How to Install C++ 17 on Linux

In this tutorial, we will show you how to quickly install C++ 17 and specify it during compilation.

How to Install C++ 17 on Linux

C++17, also known as «ISO/IEC 14882:2017,» is a version of the C++ programming language. It is the successor to C++14 and was standardized by the International Organization for Standardization (ISO) in 2017.

C++17 introduces several new features and improvements to the language, aiming to make C++ code more expressive, concise, and efficient. Some of the key additions and enhancements in C++17 include:

  1. Structured Bindings — Allows unpacking of structured types (such as tuples or arrays) into individual variables using a more concise syntax.
  2. if/switch with Initialization — Allows variables to be defined and initialized within the condition of if and switch statements.
  3. constexpr if — Introduces compile-time conditional statements, enabling selective compilation of code based on constexpr conditions.
  4. Inline Variables — Enables the definition of variables inside a class definition, making it easier to define constants or small utility objects.
  5. Range-based for loop with initializer — Allows the initialization of the loop variable directly within the range-based for loop.
  6. Fold Expressions — Simplifies the handling of variadic templates by providing a concise syntax for operations such as folding a parameter pack with a binary operator.
  7. Structured Attributes — Adds attributes to enable structured bindings and other constructs to be used with standard attributes like nodiscard and fallthrough .
  8. Parallel Algorithms — Introduces standard parallel algorithms to leverage multi-core processors efficiently.
  9. Filesystem Library — Provides a standardized library for file system operations, including file and directory manipulation, path handling, and file metadata.
  10. Standardized Attributes — Adds new standard attributes, like maybe_unused , nodiscard , and fallthrough , to improve code clarity and maintainability.

These are just a few of the new features and enhancements introduced in C++17. The goal of C++17 was to improve developer productivity, enhance the language capabilities, and provide more straightforward and safer ways to write C++ code.

Install C++ 17 on Linux

To install C++17 on Linux, you need to ensure that you have a compatible compiler. Here’s a step-by-step guide to installing C++17 on Linux using the GNU Compiler Collection (GCC):

Update Package Manager — Open a terminal and update your package manager to ensure you have the latest package information:

Install GCC — If you haven’t installed GCC already, you can install it using the following command:

Источник

Оцените статью
Adblock
detector