Installing gcc on linux - c++

How to install gcc version 4.8 on centos or scientific linux operating systems which require yum for installing.
I tried to download gcc from https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/ and then ran ./configure and then make. After running make it gives me the error: configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
Is there some way by which I may install gcc version 4.8 on linux using yum install
I tried:
1). I tried with yum --enablerepo=testing-2-devtools-6 install devtoolset-2-gcc devtoolset-2-gcc-c++ it gives me repository not found
2). yum group install "Development Tools". It gives me Package gcc-4.4.7-11.el6.x86_64 already installed and latest version
3). building it from scratch, you'll have to do ./contrib/download_prerequisites first to get MPFR, GMP and MPC in the GCC source tree, then make a separate directory and run /path/to/gcc/source/configure.
It gives:
configure: error: building out of tree but /home/Softwares/gcc-4.8.2
contains host-x86_64-unknown-linux-gnu

https://access.redhat.com/documentation/en-US/Red_Hat_Developer_Toolset/3/html/3.0_Release_Notes/DTS3.0_Release.html#Features
Install the Red Hat Developer Toolset 3.0 (or 2.X) in a way similar to what is described here. (Basically you use a repo someone else built for CentOS).

Google says to try
yum group install "Development Tools"
check out: http://www.cyberciti.biz/faq/centos-rhel-7-redhat-linux-install-gcc-compiler-development-tools/

Related

install llvm binaries without version number

When I install llvm using command
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
The binaries that get installed looks like following
All the binaries have version number. For e.g. llvm-objdump-15.
But the tools I use are looking for llvm-objdump, while installer installed it as llvm-objdump-15. I can create a symbolic link with name llvm-obdump, but I want to know how to install it correctly and not have version numbers in all these binaries?
I fixed it by using apt-get install
sudo apt-get install clang-format clang-tidy clang-tools clang clangd libc++-dev libc++1 libc++abi-dev libc++abi1 libclang-dev libclang1 liblldb-dev libllvm-ocaml-dev libomp-dev libomp5 lld lldb llvm-dev llvm-runtime llvm python3-clang
It did install an older version, but it was fine for my needs
The names without version numbers are controlled by the llvm-defaults package on your distribution. It picks a specific version to make the default, and only that one has un-versioned symlinks installed into the system PATH.
As a consequence, on Debian based systems only one version (controlled by the distro) is going to be available there and it may not be the one from https://apt.llvm.org/. On these systems, the recommended way to use a specific version is to add the suffix.
If you can't do that, you should install the distro-provided version using the normal process rather than the versions on https://apt.llvm.org/.
To read more details about how all of this works, you can check out the documentation for the llvm-defaults package set here: https://salsa.debian.org/pkg-llvm-team/llvm-defaults/-/blob/experimental/debian/README.Debian

How to build g++ 10/C++20 on WSL2?

I would like to try out the new features of C++20 on Windows 10 & WSL2. Since my ubuntu on WSL2 was very old (16), I followed these instructions:
sudo apt update -y # makes apt system itself up-to-date
sudo apt dist-upgrade -y # updates Ubuntu 18.04 packages to latest
sudo do-release-upgrade # performs the upgrade to Ubuntu 20.04
Midway thru these directions for building g++ 10, I execute
contrib/download_prerequisites
and I get this error:
error: You must run this script in the top-level GCC source directory
The problem line of code seems to be
[ -e ./gcc/BASE-VER ] \
|| die "You must run this script in the top-level GCC source directory"
The problem is that while there is a gcc directory, there is no BASE-VER directory.
Is there a better set of instructions I should use? Is there a bug in this script?
Thanks
Siegfried
Being unfamiliar with WSL2 I cannot be sure, but this looks to me like...
[ -e ./gcc/BASE-VER ] should be referring to gcc/$BASE_VER or some such. Does it look like such a directory exists?
Also those apt commands updated you to version 18.04 of Ubuntu. do-release-upgrade goes one version at a time, roughly speaking. Assuming (?) you are on a LTS release (16.04) it will bump yu up one major version to the 18.04 version (major version numbers are even - a fact I only just noticed and I have been using Ubuntu since vit started....)

how to install C++14 on RHEL 7.4

My question is similar to how to install gcc 4.9.2 on RHEL 7.4
But I'm trying to get C++14 support on Red Hat 7 so I can install mapnik.
I've tried:
# yum-config-manager --enable rhel-server-rhscl-7-rpms
Install gcc, g++ version 4.9.2 :
# yum install devtoolset-3-gcc-c++
Enabling gcc-4.9, g++-4.9 : $ scl enable devtoolset-3 bash
But I keep getting
C++ compiler does not support C++14 standard (-std=c++14), which is required. Please upgrade your compiler
The issue is that devtoolset-3 contains the c++11 standard. Making and installing GCC from source caused two GCC versions to exist together. The default being the c++11 version. In order to get the correct version of gcc I needed to install devtoolset-7 and make sure devtoolset-3 was superseded or removed.
Here is how I enabled it:
1. Install a package with repository for your system:
On RHEL, enable RHSCL repository for your system:
$ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
2. Install the collection:
$ sudo yum install devtoolset-7
3. Start using software collections:
$ scl enable devtoolset-7 bash
You can download GCC sources and build it.
Generally the process involve:
Download tar.gz with GCC source code, from here: https://ftp.gnu.org/gnu/gcc/
Configure, Make and install. You can look for documentation in their site on how to do it, specifically you can start here:
https://gcc.gnu.org/wiki/InstallingGCC

How to install libbz2 in cross compiler g++-arm-linux-gnueabifh on Ubuntu 14.04

I am using arm-linux-gnueabihf-g++-4.8 on an amd64 machine to cross compile boost targeting ARM 32-bit architecture. My OS is Ubuntu 14.04.
It fails to build lib libboost_iostreams because libbz2 does not comes with the compiler. Following is the error detail,
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lbz2
collect2: error: ld returned 1 exit status.
Having a hard time figure out how to install this libbz2 for arm-linux-gnueabihf-g++-4.8. Did not find much document online. Need some help. Thank you very much!
I'd install libbz2-1.0:armhf from Debian jessie repository.
Actually, it is present in the Ubuntu repositories too.
Configure package manager to manage ARM packages:
sudo dpkg --add-architecture armhf
Ubuntu 14.04 codename is 'trusty', so add ARM repositories for trusty by adding the line to the /etc/apt/sources.list file:
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main
Then update package index:
sudo apt-get update
Install libbz2 for ARM (but abort if it asks to remove any packages):
sudo apt-get install libbz2-1.0:armhf
If apt-get asks to remove half of the system in order to install something big like libc6:armhf, libgcc:armhf, build-essential:armhf etc. then there is a dependency resolution session ahead. There is no precise guide to that.
Also, one minor thing: you may want to add [arch=amd64,i386] annotations to all other repositories in /etc/apt/sources.list to avoid warnings.

How can I build the GPL and LGPL version of Xuggle Xuggler?

Are there specific steps I can take to build the Xuggle Xuggler source code from Windows 32-bit, Windows 64-bit, Linux 32-bit, and Linux 64-bit? I've tried multiple times on multiple systems and keep getting lots of different errors.
Update
I spent several days trying to get Xuggle Xuggler to compile (and
cross-compile). I successfully tackled compiling both the original GPL
version of the code and an LGPL version. I thought I'd post an
answer to my own question on Stack Overflow to share my knowledge.
Update on Raspberry Pi
I was also able to build and run Xuggler on the Raspberry Pi following these same basic instructions below. I just used
my LGPL version of the code that I maintain on Github, and made modifications for the Pi. I can use the compiled JAR file and binaries on my Radxa Rock (another ARM device) too. If you're interested
in building on the Pi, you can use my pi branch:
https://github.com/e-d/xuggle-xuggler
If you are lazy and just want the precompiled .jar files for the Pi/ARM:
GPL Version (supports H.264)
LGPL Version (no H.264 support)
Here is a formatted version of my answer in a published Google Document.
For completeness (and in case the link goes dead one day), here is less-nicely-formatted text:
Building Xuggle Xuggler (GPL and LGPL Licensed Versions)
[Linux 32-bit, Linux 64-bit, Windows 32-bit, Windows 64-bit]
To build the Xuggle Xuggler library, you will need two Linux virtual machines running Ubuntu 11.10 (32-bit and 64-bit operating systems). A 32-bit version of the OS is required to build Linux 32-bit, cross compiling Windows 32-bit, and cross compiling Windows 64-bit binaries. A 64-bit version of the OS is required to build Linux 64-bit binaries.
Using VirtualBox, I created the two virtual machines discussed above with the ubuntu-11.10-server-i386.iso and ubuntu-11.10-server-amd64.iso disk images. These are headless server versions of Ubuntu. After installation of the OS, follow these steps to build Xuggler (you are welcome to try different dependency versions and not use the root user, but this is what I did to build successfully):
Change to root user:
sudo su
Just use root’s home directory:
cd /root
Update apt-get to use specific repository:
apt-get install python-software-properties
add-apt-repository ppa:ferramroberto/java
apt-get update
Install Java:
apt-get install sun-java6-jdk sun-java6-plugin
Verify the HotSpot Java 6 JVM is the default java:
java -version
If the incorrect version of Java appears, configure the default by running:
update-alternatives --config java
Install gcc, g++, make and all the other build essentials:
apt-get install build-essential
Install YASM:
apt-get install yasm
Install Open SSL:
apt-get install openssl
Install Package Config:
apt-get install pkg-config
Install Git:
apt-get install git
Install Ant:
apt-get install ant-optional
Install JUnit:
apt-get install junit
Install MingGW to be able to build for Windows (mingw-w64 can do 32 and 64-bit Windows):
apt-get install mingw-w64
Download the LGPL configured Xuggle source code (Ed’s fork of the code from Jeff Wallace’s fork from the original GPL xuggle code) or the original GPL version:
LGPL: git clone https://github.com/e-d/xuggle-xuggler.git
GPL: git clone https://github.com/xuggle/xuggle-xuggler.git
Compile and build the JAR files (with binaries inside). Be sure to run the 64-bit Linux build on the 64-bit version of Ubuntu. Also note that between builds you will need to run “ant clobber” to remove all of the compiled files from the previous architecture. To build run:
(32/64-bit Linux): ant stage
(64-bit Windows): ant -Dbuild.configure.os=x86_64-w64-mingw32 stage
(32-bit Windows): ant -Dbuild.configure.os=i686-w64-mingw32 stage
The JAR files will be in the /dist/lib directory.
If you need the Linux binaries to additionally work on CentOS, you’ll now need to change the version of GCC and G++ to use 3.4 instead of 3.6.
Install GCC 4.4:
apt-get install gcc-4.4
Update symbolic links to use 4.4 (the arch-specific link will be different on 32-bit VM):
rm /usr/bin/gcc
ln -s /usr/bin/gcc-4.4 /usr/bin/gcc
rm /usr/bin/x86_64-linux-gnu-gcc
ln -s /usr/bin/x86_64-linux-gnu-gcc-4.4 /usr/bin/x86_64-linux-gnu-gcc
Install C++ (G++) 4.4:
apt-get install c++-4.4
Update symbolic links to use 4.4 (the arch-specific link will be different on 32-bit VM):
rm /usr/bin/cpp
ln -s /usr/bin/cpp-4.4 /usr/bin/cpp
rm /usr/bin/x86_64-linux-gnu-cpp
ln -s /usr/bin/x86_64-linux-gnu-cpp-4.4 /usr/bin/x86_64-linux-gnu-cpp
rm /usr/bin/g++
ln -s /usr/bin/g++-4.4 /usr/bin/g++
rm /usr/bin/x86_64-linux-gnu-g++
ln -s /usr/bin/x86_64-linux-gnu-g++-4.4 /usr/bin/x86_64-linux-gnu-g++
Verify default versions:
gcc --version
c++ --version
cpp --version
gcc --version
You can now run the builds the same way as before (you only need to re-build Linux binaries). The binaries will now be compatible with slightly older versions of many Linux distros (including CentOS compatibility). These 4.4 compiled binaries should still work everywhere the 4.6 compiled versions would run too.
Special thanks to this blog for pointing me in the right direction and giving me the majority of what I detailed above.