Install g++ 4.9 on Mint 17.2 - c++

I'm trying to install g++ 4.9 or greater in order to build mapbox on Android. The instructions state I need g++ 4.9 or greater. I found the following instructions, but they don't work.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9
The last command says:
~ $ sudo apt-get install g++-4.9
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package g++-4.9 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'g++-4.9' has no installation candidate
I also tried from Synaptic Package Manager and got the following:
g++:
Depends: cpp (>=4:4.9-1ubuntu7) but 4:4.8.2-1ubuntu6 is to be installed
Depends: gcc (>=4:4.9-1ubuntu7) but 4:4.8.2-1ubuntu6 is to be installed
Depends: g++-4.9 (>=4.9) but it is not installable
Depends: gcc-4.9 (>=4.9) but it is not installable
How can I get g++ 4.9 on my computer?
Thanks.

Here is how to install g++-4.9 on Linux Mint 17.2 Rafaela
Go to menu -> Administration -> Software sources
Click on Additional repositories and then Getdeb
Click on Edit URL...
Replace deb http://archive.getdeb.net/ubuntu trusty-getdeb apps
by
deb http://archive.getdeb.net/ubuntu wily-getdeb apps
and click on Update the cache
At this point you can go with
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9
You can invoke your g++ like this:
g++-4.9
Now you have g++ 4.9.3 installed
And as an add, you can have the latest g++-5 (g++ 5.2.1) compiler
sudo apt-get install g++-5

Related

What are the steps to build LLVM from source for Ubuntu Bionic Beaver?

Not all Kaleidoscope examples compile. Some do.
In the build process of LLVM Cmake complains "- Failed to find LLVM FileCheck"
My interest is in developing a toy compiler using LLVM - on a Ubuntu Bionic Beaver laptop, 64 bit. Therefore I needed to compile LLVM from source. The documentation says Cmake, gcc/g++, clang and zlib are required for the build. Yes, that is true. I found out the hard way this list is incomplete.
sudo apt update
sudo apt upgrade
sudo apt install -y cmake gcc g++ python build-essential opam ocaml
sudo apt install -y checkinstall python-pygments python-yaml llvm
opam init /* and say yes to creating a profile
opam config env
opam install ctypes ctypes-foreign
opam depext conf-llvm.6.0.0 /* and said Y to install
opam depext conf-m4.1 /* and said Y to install
opam depext conf-pkg-config.1.1 /* and said Y to install
sudo apt install libxml2-dev libplist-dev
sudo apt install llvm-7-tools
/*the z3 package is outdated, need to build from source:
mkdir z3 /*somewhere
git clone https://github.com/Z3Prover/z3
python scripts/mk_make.py
cd build
make
sudo checkinstall /* y and enter
cd <to sourceroot of llvm>
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build; cd build
cmake -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release ../llvm
make -j2
Kaleidoscope examples from Chapters 3 and 8 compile fine. The output from the toy compiler resulting from Chapter 8 even does compile and link to a working program. The examples from the Chapters 2, 4, 5, 6, 7 and 9 don't compile.
You also need googletest as a shared library with current source code (27-04-2019) for it to compile. It is not stated as a requirement which was very frustrating when I had errors building llvm, clang, lld and clang extra tools.
Best place for the current code is: github.com/google/googletest
The best answer for how to build googletest is here

django channels install error

I am trying to create a one to one real-time messaging system using Django. Upon searching I found out about django-channels. So i created a virtual env with python 3.5 and latest Django but when I do pip install channels I get :
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/kshitij/Documents/projects/personal/maker/venv/include/python3.5m -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-3.5/src/twisted/test/raiser.o
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
probably because of missing python headers so i did : sudo apt-get install python3-dev but it still shows the same error. What should I do?
pip version: 18
python version: 3.5
django version: 2.1
I tried doing sudo apt-get install python3-dev but getting:
ImportError: cannot import name '_BACKCOMPAT_MAGIC_NUMBER'
Verify your pip is not pip and its pip3.
You may also try installing sudo apt install python3.X-dev.
For you, it's sudo apt install python3.5-dev
Try installing the Linux compiler and python3-dev:
sudo apt install gcc
sudo apt install python3-dev
pip install channels
The last error may indicates you have an issue caused by many python versions installed on your system (see this answer). You should make sure you don't have incomplete or corrupted python installation on your system (did you already compiled Python by yourself?). In addition, make sure the package python3 is correctly installed or sudo apt-get install python3-dev cannot succeed.
In addition, you may try to locate Python.h on your system. Make sure each Python.h on your system correspond to a valid python setup (you may have one for python 2 and one more for python 3).

Update g++ but still old version

I installed g++ using those commands line:
sudo add-apt-repository ppa:jonathonf/gcc-7.1
sudo apt-get update
Then
sudo apt-get install gcc-7 g++-7
When it was done I tried g++ -v but still shows me the old version
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
Am I not upgrading it correctly?
Edit
:~$ dpkg -L g++-7
/.
/usr
/usr/lib
/usr/lib/gcc
/usr/lib/gcc/x86_64-linux-gnu
/usr/lib/gcc/x86_64-linux-gnu/7
/usr/lib/gcc/x86_64-linux-gnu/7/cc1plus
/usr/share
/usr/share/doc
/usr/share/doc/gcc-7-base
/usr/share/doc/gcc-7-base/C++
/usr/share/doc/gcc-7-base/C++/README.C++
/usr/share/doc/gcc-7-base/C++/changelog.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/x86_64-linux-gnu-g++-7.1.gz
/usr/bin
/usr/bin/x86_64-linux-gnu-g++-7
/usr/share/doc/g++-7
/usr/share/man/man1/g++-7.1.gz
/usr/bin/g++-7
:~$ which g++
/usr/bin/g++
Installing a newer (or older) version of GCC than the Ubuntu default version via the package manager
does not delete the default version. You get both. You can install as many
versions as you like. gcc/g++ will continue
to run the default version. If you have installed GCC 7, then you run
the new compilers with gcc-7 or g++-7. For most build systems, it is sufficient to set the environment variables CC=gcc-7 CXX=g++-7 before starting the build.
I installed the gcc-7 using the directions given in Ubuntu Forum, rebooted the system (to make sure all environment variables are loaded) and to compile with C++ 17, type the following on the shell :
g++-7 -std=c++17 program_name.cpp -o program.out
Hope this helps.

How to recover default boost installation on ubuntu?

I was trying to compile boost 1.62 from source on ubuntu 12.04 where the default version is 1.48. During the course of trying everything, I removed boost from /usr/include/boost and libboost* from /usr/lib using the following commands
sudo rm -r /usr/include/boost
sudo rm -r /usr/include/libboost*
I have realized that now I need the default version (1.48) for my program to work. But when I use the following command
sudo apt-get install libboost-dev-all
it seems to install the libboost, but I am not able to see any boost directory in /usr/include. Moreover, I tried compiling a few programs with cmake and it also doesn't seem to find any boost library on the system.
Is it not possible to reinstall libboost if the libraries and headers have been removed manually ?
from the ubuntu forums :
choices:
sudo apt-get install --reinstall mypackage
sudo dpkg-reconfigure mypackage
( or if the other solutions have failed:
sudo apt-get purge mypackage && sudo apt-get install mypackage
and logout/in )
give it a shot !
also if you don't see any librarie after installing one you can run :
sudo ldconfig
The above command will make ld (the dynamic libraries loader) aware of the new libraries.

How to change arm version in arm-linux-gnueabi-gcc for cross compile

I want to cross-compile in eclipse for board armv7l.
I got the armv7l via, uname -i.
I installed ARM cross compiler toolchain, using below commands.
$ sudo apt-get install emdebian-archive-keyring
$ sudo apt-get install libc6-armel-cross libc6-dev-armel-cross
$ sudo apt-get install binutils-arm-linux-gnueabi
$ sudo apt-get install gcc-arm-linux-gnueabi
$ sudo apt-get install g++-arm-linux-gnueabi
$ sudo apt-get install u-boot-tools
$ sudo apt-get install libncurses5-dev
I think I have to give an option for my target board version.
First time I tried to put arm-linux-gnueabi-g++ in C/C++ Build->settings->GCC C++ Compiler and GCC C++ Linker.(eclipse project properties)
Next I put -march=armv7 in Miscellaneous
But it was not working. I checked the executable file with readelf -A
and it shows this
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv3-D16
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_HardFP_use: SP and DP
Tag_CPU_unaligned_access: v6
Tag_DIV_use: Not allowed
What option I have to put for my target board ?