how to install gcc-12 on ubuntu - linux

$ sudo apt search gcc-12
Sorting... Done
Full Text Search... Done
$ uname -a
Linux Han 5.10.81.1-microsoft-standard-WSL2 #1 SMP Mon Nov 22 18:52:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
I am using the default sources.list file, I want to install gcc-12 but I can't find it in the mirror source, what should I do!

gcc-12 is not available in ubuntu 20.04, so we need to compile it from source code, here are the steps which I borrowed from this video:
Step 1: clone gcc source code and checkout gcc-12 branch
$ git clone https://gcc.gnu.org/git/gcc.git gcc-source
$ cd gcc-source/
$ git branch -a
$ git checkout remotes/origin/releases/gcc-12
Step 2: make another build dir
Note this is important as running ./configure from within the source directory is not supported as documented here.
$ mkdir ../gcc-12-build
$ cd ../gcc-12-build/
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
Step 3: installing GCC prequisites and run configure again
The missing libraries will be shown in above ./confgiure output, search and install them one by one.
$ apt-cache search MPFR
$ sudo apt-get install libmpfrc++-dev
$ apt-cache search MPC | grep dev
$ sudo apt-get install libmpc-dev
$ apt-cache search GMP | grep dev
$ sudo apt-get install libgmp-dev
$ sudo apt-get install gcc-multilib
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
An alternartive is to run the download_prerequisites script.
$ cd ../
$ cd gcc-source/
$ ./contrib/download_prerequisites
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
Step 4: compile gcc-12
$ make -j16
Still flex is missing:
$ sudo apt-get install flex
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
$ make -j16
$ make install
Another way is to use Ubuntu 22.04 where gcc-12 is available. In Ubuntu 22.04, gcc-12 can be installed with apt:
$ sudo apt install gcc-12

You can use Homebrew to install pre-built binaries.
Follow instructions to install Homebrew at https://brew.sh/, then
brew install gcc for default GCC (currently 11) or brew install gcc#12 for gcc-12.
Note that it may compile missing dependencies.

I would add if you are adding for 64 bit only, you'll want to add "--disable=multilib" to the end of your configure statement.

Related

Trying to jail linux users using bubblewrap on ubuntu 18.04

I ran the below commands as root to install bubblewrap:
$ apt install pkg-config libcap-dev automake
$ git clone https://github.com/containers/bubblewrap.git
$ cd bubblewrap
$ git checkout v0.4.1
$ ./autogen.sh
$ make
$ make install
$ ln -s /usr/local/bin/bwrap /bin/bwrap
$ mv /usr/bin/bwrap /usr/bin/bwrap.dist
$ ln -s /usr/local/bin/bwrap /usr/bin/bwrap
It got installed. Now I want to jail/unjail some already created users using bubblewrap. I am not able to find any commands to do so. I want to know how to jail/unjail users using bubblewrap(bwrap).

Install Julia >v1.1.1 on Raspberry Pi Zero W

I'm trying to use the PortAudio package in Julia on a Raspberry Pi Zero W running Raspberry Pi OS like so:
using Pkg
Pkg.add("PortAudio")
This fails with the error:
ERROR: Unsatisfiable requirements detected for package PortAudio [80ea8bcb]:
PortAudio [80ea8bcb] log:
├─possible versions are: 1.1.1-1.1.2 or uninstalled
├─restricted to versions * by an explicit requirement, leaving only versions 1.1.1-1.1.2
└─restricted by julia compatibility requirements to versions: uninstalled — no versions left
The version of Julia in apt is v1.0.3, which explains the above error. So I'm trying to install the latest version of Julia. The pre-compiled binaries won't run (Illegal instruction error) so I'm trying to compile it following the instructions from here:
sudo apt-get -y update
sudo apt-get install build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config libopenblas-dev git ccache
I then added this to /etc/dphys-swapfile
CONF_SWAPSIZE=8192
CONF_MAXSWAP=8192
Then
git clone https://github.com/JuliaLang/julia.git
cd julia
git checkout v1.6.2
make
This fails with this error:
Illegal instruction
make[1]: *** [Makefile:222: julia_flisp.boot] Error 132
make: *** [Makefile:43: julia_flisp.boot.inc.phony] Error 2
I think the issue here is that you need to tell it which ARM CPU the Pi uses, so following these instructions and this thread I added this to Make.user:
JULIA_CPU_TARGET=arm1176jzf-s
USE_BINARYBUILDER=0
But I get the same error, albeit with a suggestion to try make -C deps clean-openblas and rebuild with make OPENBLAS_USE_THREAD=0 or make OPENBLAS_TARGET_ARCH=NEHALEM. Neither fixes the problem. Also tried this python script (error downloading julia-1.6-latest ) and these instructions to install via docker (standard_init_linux.go:228: exec user process caused: exec format error) but could not get either to work.
I've tried absolutely everything I can find online. Someone please help! How do I install a recent version (>v1.1.1) of Julia on a Pi Zero?
I did it! Code quoted from this website:
yourmainPC $ ssh pi#raspberrypi.local # Assume You are going to login to your Pi via SSH
pi#raspberrypi $ curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
pi#raspberrypi $ sudo gpasswd -a $USER docker # if you like to skip `sudo`
pi#raspberrypi $ exit
yourmainPC $ ssh pi#raspberrypi.local # login again
pi#raspberrypi $ JL_VERSION=v1.5.1
pi#raspberrypi $ IMAGE_NAME=terasakisatoshi/jlcross:rpizero-${JL_VERSION}
pi#raspberrypi $ CONTAINER_NAME=jltmp_${JL_VERSION}
pi#raspberrypi $ docker run --name ${CONTAINER_NAME} $IMAGE_NAME /bin/bash
pi#raspberrypi $ docker cp ${CONTAINER_NAME}:/home/pi/julia-${JL_VERSION} .
pi#raspberrypi $ docker rm ${CONTAINER_NAME}
pi#raspberrypi $ ls
julia-v1.5.1 # <---- this is it
pi#raspberrypi $ cd julia-v1.5.1/bin
pi#raspberrypi $ ./julia # tada!!!

Python3.8 on Ubuntu 14.04

I am trying to install Python3.8 on Ubuntu 14.04, I get this error:
E: Unable to locate package python3.8 E: Couldn't find any package by
regex 'python3.8'
Is it even possible to have python3.8 on Ubuntu that is that old? If it is possible, please tell me how.
EDIT
When installing from source ( I followed that instruction)
I get this error:
Fatal Python error: _PySys_InitCore: can't initialize sys module
Python runtime state: preinitialized
Current thread 0x00002ab78e1b3740 (most recent call first): generate-posix-vars failed make: *** [pybuilddir.txt] Error 1
An alternative solution could be to compile python statically on a newer system. Then such binaries can be transferred to the target system.
Compilation tested on vanilla Ubuntu 20.04 LTS
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
$ sudo apt-get install build-essential checkinstall
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
$ wget https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tgz
$ tar xzf Python-3.8.6.tgz
$ cd Python-3.8.6
$ ./configure LDFLAGS="-static" --disable-shared
$ make LDFLAGS="-static" LINKFORSHARED=" "
....
$ cd ..
$ zip -r Python-3.8.6.zip Python-3.8.6
Transfer Python-3.8.6.zip to target sysytem
$ unzip Python-3.8.6.zip
$ cd Python-3.8.6
$ ./python
Of course you would have to do
make install
or clean this folder, that's your choice.
Normally, as long as you are not using any kind of dockerization/paravirtualization, simple:
sudo snap install python38
should work.

How to reinstall the latest cmake version?

I would like to install cmake the latest version, on Linux environment. I have cmake version 3.5 installed and is not supported by some applications. I tried to upgrade it by uninstalling the current version. But when I reinstall with sudo apt-get install cmake, I get the same version 3.5 re-installed. How do I install the latest version with sudo apt-get install ....?
As far as I know the best way to get the latest CMake version installed on any Linux is not by apt but using pip.
Remove the apt cmake and install the latest version from pip which can easily keep up-to-date.
apt remove cmake -y
pip install cmake --upgrade
Edit: As GNUton has pointed out, the following only works on Ubuntu 16.04 and 18.04(Checked on June 2019).
Now CMake developer team in Kitware Inc provides APT repositiory. It allows you to install latest CMake via apt-get.
If you are using a minimal Ubuntu image or a Docker image, you may need to install the following packages:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg \
software-properties-common wget
Obtain a copy of our signing key:
wget -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc |
sudo apt-key add -
Add the repository to your sources list and update.
For Ubuntu Bionic Beaver (18.04):
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt-get update
For Ubuntu Xenial Xerus (16.04):
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main'
sudo apt-get update
... Optional steps. See details in reference.
... Optional steps. See details in reference.
Now call
sudo apt-get install cmake
Reference: Kitware APT Repository.
You can try the following steps that have worked for me on Ubuntu 18.04.3 LTS as OS of the NVIDIA jetson Nano to get the last version of cmake "cmake-3.14.0" from https://cmake.org/download/.
Delete the installed version in your system
sudo apt purge cmake
Download cmake3.13.4 source
wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4.tar.gz
Extract files
tar zxvf cmake-3.13.4.tar.gz
Execute the following commands in this order to build it
cd cmake-3.13.4
sudo ./bootstrap
sudo make
sudo make install
Verify the version is installed correctly
cmake --version
Following the comments made on how to Install the latest CMake version and to post the answer for this question:
Ans:
This depends with Ubuntu OS version currently installed on your PC or Mac. If you have the following Ubuntu OS version then you have this CMake installed or that you could install and reinstall with "sudo apt-get install cmake". Even if you uninstall your version and try to reinstall later version.
Ubuntu 16.04 ships with cmake-3.5.1
Ubuntu 17.10 ships with cmake-3.9.1
Ubuntu 18.04 ships with cmake-3.10.2
Ubuntu 20.04 ships with cmake-3.16.3
Ubuntu 21.04 ships with cmake-3.18.4
Now if you have Ubuntu 16.04 installed and you want cmake-3.10, there is OS problem since you can only install and reinstalled cmake-3.5.1. To get cmake-3.10 or any other version, you have to download and install the package from https://packages.ubuntu.com/. Once you find the latest version of cmake .targz files, you have to build it yourself from the command line.
For CentOS/RHEL you can help these following steps:
yum -y install python-pip
pip install cmake --upgrade
If you are using Google Colab like me and wanted a higher version of cmake in it. Then do the following,
!pip uninstall cmake
!pip install cmake
This will install cmake 3.22 instead of the default version 3.12
pip install cmake --upgrade
if the following occurs after cmake .. :
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/.../.../...
CMake Error: Error executing cmake::LoadCache(). Aborting.
then try
hash -r
the following worked for me:
sudo apt remove cmake
pip install cmake --upgrade
then, I exited the terminal and again entered to check the version with cmake --version command
3.20.5 in ubuntu 16.04
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main'
sudo apt update
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DE19EB17684BA42D
sudo apt install cmake cmake-qt-gui cmake-curses-gui
yum remove cmake
wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4.tar.gz
tar zxvf cmake-3.13.4.tar.gz
cd cmake-3.13.4
sudo ./bootstrap --prefix=/usr/local
sudo make
sudo make install
vi ~/.bash_profile
...
# PATH=$PATH:$HOME/bin
PATH=/usr/local/bin:$PATH:$HOME/bin
export PATH
source ~/.bash_profile
cmake --version
vi ~/.bash_profile
centos7 it help me
In case someone still finds it hard to remove cmake from their machine.
This command works for me (requires sudo permissions):
$ sudo find / -name "cmake" | xargs -I % sudo rm -rf "%"

(ONIE) stg: command not found and Error 127 in Ubuntu terminal

I was trying to follow this guide: https://github.com/opencomputeproject/onie/blob/master/machine/kvm_x86_64/INSTALL but have gotten stuck.
On this line: make MACHINE=kvm_x86_64 all, I get stg: command not found when it is trying to apply a patch. I get Error 127 on a make command. Here's the output:
I have g++ and git installed. What am I doing wrong?
From the ONIE project wiki Building ONIE:
For a Debian-based system, a Makefile target exists that installs the required packages on your build machine. The ONIE project will maintain this target for the current stable version of Debian. This target requires the use of sudo(8), since package installation requires root privileges:
$ cd build-config
$ sudo apt-get update
$ sudo apt-get install build-essential
$ make debian-prepare-build-host
I built this on Ubuntu Desktop 15.04. For anyone else trying to build ONIE virtual machine, install these packages first:
Packages
qemu-kvm
git
stg
gperf
bison
flex
autoconf
texinfo
gawk
libtool
libtool-bin
libncurses5-dev
libexpat1
libexpat1-dev
python2.7-dev
python3.4-dev
xorriso
You can install most of these with sudo apt-get install <package>. You should be able to follow the ONIE guide now and set it up. Thanks to EtanReisner for all the help!
On Ubuntu, install stg package by,
sudo apt-get install stgit
the error stg: command not found should be resolved.

Resources