Installing Boost in Linux - linux

I recently set up an AWS EC2 Linux instance, and I'm trying to install boost using the following code:
wget -c
http://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.bz2
tar jxf boost_1_66_0.tar.bz2
cd boost_1_66_0
sudo ./bootstrap.sh --prefix=/usr/local/
./b2
sudo ./b2 install
When I run this, I get the following:
error: toolset gcc initialization:
error: no command provided, default command 'g++' not found
error: initialized from project-config.jam:12
Also, when I tried installing g++, which I thought I had already done by issuing this:
sudo yum install gcc-c++
The result:
Package gcc-c++-4.8.5-1.22.amzn1.noarch already installed and latest version
Nothing to do

On AWS Linux the way to go is described here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/compile-software.html
Or execute command:
sudo yum groupinstall "Development Tools"
This should help.

It seems like you are missing other build tools required for compiling. Installing following should fix your problem,
sudo yum install -y gcc libxml2-devel gcc-c++ make
You can uninstall the tools afterwards.

Related

How do I fix the Rust error "linker 'cc' not found" for Debian on Windows 10?

I'm running Debian on Windows 10 (Windows Subsystem for Linux) and installed Rust using the command:
curl https://sh.rustup.rs -sSf | sh
There were no errors in the install, but when I tried to compile with rustc I got the error linker 'cc' not found.
The Linux Rust installer doesn't check for a compiler toolchain, but seems to assume that you've already got a C linker installed! The best solution is to install the tried-and-true gcc toolchain.
sudo apt install build-essential
If you need to target another architecture, install the appropriate toolchain and target the compilation as follows:
rustc --target=my_target_architecture -C linker=target_toolchain_linker my_rustfile.rs
I ran the following 2 commands and it worked.
sudo apt-get update
sudo apt install build-essential
You have to install some dependencies
for Arch Linux sudo pacman -S base-devel
for Ubuntu sudo apt install build-essential
for Centos sudo yum install gcc
for Solus sudo eopkg it -c system.devel
Solution for CentOS:
yum -y install gcc
if u are on wsl2 - ubuntu try to update the pacakges with following cmds:
sudo apt-get update
sudo apt install build-essential
Solution for Solus:
sudo eopkg it -c system.devel
Please do an "Update and Upgrade" before installing setup tools.
You can fix this problem by adding build essential package in linux
sudo apt install -y build-essential
IF ABOVE IS NOT WORKING: cc is included in the "GCC" package. You need to uninstall GCC and then reinstall it if you have accidentally replaced or removed the cc binary.
I ran the following commands in wsl1, it worked
sudo apt-get update
sudo apt install build-essential

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 "%"

Install gcc on AWS EC2 without using yum?

I am trying to install Redis on EC2 but it needs gcc. When I tried gcc was not installed.
Then I tried to install gcc manually and got the following error:
configure: error: could not find a working compiler, see config.log for details
How can I solve this?
If you use a standard AMI Linux instance, you can install gcc simply by running:
sudo yum groupinstall "Development Tools"
On a SuSE instance, you can try:
sudo zypper install gcc
I copied form user7706975's answer
1 Download gcc version from gcc.parentingamerica.com/releases.
2 Compile it from Gcc Wiki for example if you want the version 4.6.2
tar xzf gcc-4.6.2.tar.gz
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.6.2/configure --prefix=$HOME/GCC-4.6.2 --enable-languages=c,c++,fortran,go
make
make install
Reference: My AWS EC2 Instance: Ubuntu 16.04

(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.

Boost Installation

I have a question regarding the installation of the boost libraries. Is there a package that I can use the sudo apt-get install to install this package. I searched all of the questions in this forum and using the commands sudo apt-get install libboost1.40-dev I cannot install theh package with this. Also, I can download it from boost.org but I do not know the correct path to install it too. I would prefer to install it using the sudo apt-get install commands if possible. I am using Ubuntu 9.04.
Thanks.
If you want to run with the latest version, you can do the bjam install as mentioned by Ralf, but I suggest you build a 'pseudo' package so you can
uninstall it safely
prevent/notice conflicts with official/existing boost packages.
Here is how to do that:
mkdir -pv /tmp/boostinst
cd /tmp/boostinst/
wget -c 'http://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.bz2/download'
tar xf download
cd boost_1_66_0/
./bootstrap.sh --help
./bootstrap.sh --show-libraries
./bootstrap.sh
checkinstall ./b2 install
On new boost version there is other way:
sudo apt-get update
wget -c 'http://sourceforge.net/projects/boost/files/boost/1.50.0/boost_1_50_0.tar.bz2/download'
tar xf download
cd boost_1_50_0
./bootstrap.sh
./b2 install
You can use command aptitude search libboost to see list of the availiable boost libraries. The last version of boost is 1.42 - maybe that's why you can't find version 1.40.
If aptitude search command don't give you sufficient results, try sudo aptitude update and then run aptitude search again.
On my version of Ubuntu (10.04) it's libboost1.40-all-dev
On your version you've probably got an older version of boost, you should just be able to tab-complete to see which version you can install.
In any case what I usually do under Ubuntu is
sudo apt-get install bjam
Extract the downloaded boost archive to your hard-drive and then cd into the root and
sudo bjam install
This way you can get the newest version of boost, and not the slightly outdated one that is available for your Ubuntu version.
This is a link which explain step by step on how to install it (give it some time read!)
http://www.boost.org/doc/libs/1_41_0/more/getting_started/unix-variants.html
but your inline shell command might be the simple and easy way for doing it

Resources