How to use latest boost version in Travis CI? - c++

I tried to install boost 1.64 in Travis CI environment in several way. But none of them was succeeded.
In my first naive attempt I just added following line in travis script:
install:
- sudo apt-get install libboost1.64-all-dev
The result was error message: cannot find package libboost1.64-all-dev
In second attempt I specified repository with necessary boost version.
before_install:
- sudo add-apt-repository -y ppa:nschloe/boost-nightly
- sudo apt-get update -qq
install:
- sudo apt-get install libboost-all-dev
# - sudo apt-get install libboost1.64-all-dev (also tried)
In the first case default boost version (1.54) was installed.
In second case result was same error message: cannot find package libboost1.64-all-dev
In third attempt I manually typed instructions to install boost:
install:
- sudo wget -O boost_1_64_0.tar.gz http://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.gz/download
- sudo tar xzvf boost_1_64_0.tar.gz
- cd boost_1_64_0/
- sudo ./bootstrap.sh --prefix=/usr/local
- sudo ./b2
- sudo ./b2 install
As result my script took more than 30 min then was terminated.
Is any simple (or just working) way to install other than default boost version to Travis CI?

To look which all packages are available (esp. when you add the extra repository), you can run the "apt-cache search" command, e.g.:
sudo apt-cache search libboost
Then you can see the available versions.
When building manually, by default it builds "everything" (all static/shared debug/release libs), which then takes a lot of time and therefore it might timeout.
You can try to build only the libraries you actually need, for examle:
./bootstrap.sh --with-libraries=program_options,filesystem,system
./b2 link=shared threading=multi variant=release
(see here for details: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html)

Precompiled Boost
Here are the steps I followed to get this to work:
Search on launchpad until I found a recent boost package build for the trusty environment. That was non trivial, but there is a currently maintained ppa from mhier called libboost-latest
I found configuring the .travis.yml correctly to use the ppa nontrivial, so I present a working snippet below which I hope will help anyone else struggling with the same problem.
The following works for clang and gcc:
language: cpp
dist: trusty
sudo: false
os: linux
matrix:
include:
- env: COMPILER=g++-6 BUILD=Debug STANDARD=14
compiler: gcc
addons:
apt:
update: true
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- ubuntu-toolchain-r-test
packages:
- g++-6
- boost1.67
- env: COMPILER=g++-6 BUILD=Release STANDARD=14
compiler: gcc
addons:
apt:
update: true
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- ubuntu-toolchain-r-test
packages:
- g++-6
- boost1.67
# the rest of your yaml file...
Hopefully mhier will keep this ppa running for a while, otherwise you'll have to go through step 1, or provide your own ppa. As the boost version numbers progress the package number will change, so check the ppa page to keep the package name up to date.
A complete working example can be found at the monstar github project.
Compiling boost from source
You can also compile boost from source within your travis build, although you run the risk of timing out. The instruction for this are found in item 12 of boost's best practice handbook

I've run into the same issue and limiting the informational output from the commands seemed to do the trick.
The three that flood the log:
- tar -xzf boost_1_64_0.tar.gz
- ./b2 -d0
- ./b2 install -d0

Related

Compiling opencv on ubuntu with C++ version 17

I'm trying to add a pnp solver to opencv
I'm working on ubuntu OS.
first I followed a tutorial on how to install opencv from source by cloning the repositories, then I tested the example and it worked so it compiled and installed succesfully.
I began adding my files and I made sure that no names are duplicated and all the files have been added so there were no issues with dependancies.
then I ran the cmake again, and ran the make command, but it is giving me the following error:-
opencv/modules/calib3d/src/RansacOptimalNPnP/../NPnP/DualVar.h:71:8: error: ‘optional’ in namespace ‘std’ does not name a template type
71 | std::optional<std::tuple<Eigen::Matrix3d, Eigen::Vector3d, double>>
I looked it up online and there is a possibility that I need to use C++ version 17 but the standard version in opencv is set to 11.
what can I change in the opencv cmake list to change that?
As I understand it Thamognya's answer, while useful to most users, misses what you are trying to do :
author and build a new module, to be compiled into the OpenCV library, (and your new module depends on C++17).
Re Setting C++ version and other options in Cmake:
To set the C++ version, and other Cmake options, I recommend using "cmake-gui". This is part of cmake, but separately installed in Ubuntu (and most Linix distros).
sudo apt-get install cmake-gui
You will find the c++ compiler options in the CMAKE_CXX* variables.
Re extending OpenCV:
If you have not already done so, I recommend cloning the OpenCV-contrib and OpenCV-extra repositories.
git clone https://github.com/opencv/opencv_contrib.git
git clone https://github.com/opencv/opencv_extra.git
These provide
examples of how to write and build new modules for OpenCV,
the data to run all the unit tests, to ensure your build is working correctly.
Re C++ version compatability:
C++ is intended to be backwards compatible, but there are details...
ABI compatability between compiler versions is a related issue.
This thread gives information on mixing versions of C++ in a library: Is it safe to link C++17, C++14, and C++11 objects
I would recommend starting by setting C++ version in "cmake-gui", and seeing if there are problems in configuration, build file generation, and compilation. Start with a minimal build and add only what you need. (i.e. Don't take on more complexity/bugs than you have to.)
OpenCV has the option to build many of its dependencies from source, (rather than using the versions you may have insalled on your operating system). This may help avoid compatability issues.
You can install OpenCV from ubuntu's opencv package via the following:
for python:
sudo apt-get install python3-opencv
for libopencv-dev:
sudo apt-get install libopencv-dev
If you want to compile it and not use ubuntu's OpenCV package, do the following:
# dependencies
sudo apt-get install cmake
sudo apt-get install gcc g++
# for python2 support
sudo apt-get install python-dev python-numpy
# for python3 support
sudo apt-get install python3-dev python3-numpy
# GTK support
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
# GTK 2 support
sudo apt-get install libgtk2.0-dev
# GTK 3 support
sudo apt-get install libgtk-3-dev
# Optional Dependencies
sudo apt-get install libpng-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libopenexr-dev
sudo apt-get install libtiff-dev
sudo apt-get install libwebp-dev
now that you are done with dependencies continue to the actual installation
sudo apt-get install git
git clone https://github.com/opencv/opencv.git
mkdir build
cd build/
cmake ../
if properly configured this is the output
-- Python 2:
-- Interpreter: /usr/bin/python2.7 (ver 2.7.6)
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
-- numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2)
-- packages path: lib/python2.7/dist-packages
--
-- Python 3:
-- Interpreter: /usr/bin/python3.4 (ver 3.4.3)
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython3.4m.so (ver 3.4.3)
-- numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.8.2)
-- packages path: lib/python3.4/dist-packages
make
sudo make install
This was shamelessly copied from opencv docs py setup in ubunutu

creating an auto installer in ubuntu

I am trying to install and run this software https://github.com/mit-biomimetics/Cheetah-Software
it's for a project but it can t compile for missing dependancies (eigen3).
I would like to create an auto install script to run it.
I have already do the most but i think i have problems in linking path in cmake and qt5.10 and eigen...
The autoinstall.sh code:
Install dependancies
sudo apt install mesa-common-dev freeglut3-dev coinor-libipopt-dev libblas-dev liblapack-dev gfortran liblapack-dev coinor-libipopt-dev cmake gcc build-essential libglib2.0-dev default-jdk python-all-dev liblua5.1-dev golang doxygen python-epydoc
Clone MIT Minicheetah software
git clone https://github.com/mit-biomimetics/Cheetah-Software.git
cd Cheetah-Software
Eigen library
wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip
unzip eigen-3.3.7.zip
lcm library
wget https://github.com/lcm-proj/lcm/releases/download/v1.4.0/lcm-1.4.0.zip
unzip lcm-1.4.0.zip
cd lcm-1.4.0
mkdir build
cd build
cmake ..
make
sudo make install
cd ..
cd ..
Qt
wget http://mirrors.ukfast.co.uk/sites/qt.io/archive/qt/5.10/5.10.0/qt-opensource-linux-x64-5.10.0.run
chmod +x qt-opensource-linux-x64-5.10.0.run
./qt-opensource-linux-x64-5.10.0.run
build
cd scripts # for now, you must actually go into this folder
./make_types.sh # you may see an error like `rm: cannot remove...` but this is okay
cd ..
mkdir build
cd build
cmake .. # there are still some warnings here
make -j
configure or setup.py or anything relqted in INSTALL or README.MD ( mandatory )
make
make install
but really you did not choose the most straitforward job, even as a developper I've been surprised many times when using cloned sources.
You should give a try to precompiled ROS for your robots or any distribution that let you install from binary yet you can still cross-compile when dev is done.
So i was able to compile and run it after several research and asking forums, it was a problem of compatibility with lcm library and openjdk, so download oracle jdk, do some linking manually and it was all good, absolutely no error in compilation.
Cheetah-Sofware-Ubuntu 18.04-AutoInstall.sh :
https://github.com/STRATOS-ROBOTICS/LeopardMK1/blob/master/install.sh

Cannot install llvm-9 or clang-9 on Ubuntu 16.04

I have not been able to install either llvm version 9 or clang version 9 on Ubuntu. We have installed them on Windows.
I have tried a command and saw this response.
sudo apt-get install llvm-9
Reading package lists... Done
Building dependency tree
Reading state information...
Done E: Unable to locate package llvm-9
I have also tried and saw this response.
sudo apt-get install clang-9
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package clang-9
My /etc/apt/sources.list file contains
deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9.0 main
I found the website and saw that the folder was llvm-toolchain-xenial-9. Trying that version did not work either.
What else can I do?
I have looked at downloading the binaries but am not sure what installation steps I might be missing. I am not interested in compiling source code.
The Clang/LLVM project provides Nightly build packages for Ubuntu and Debian.
See the https://apt.llvm.org
The goal is to provide Debian and Ubuntu [Clang and LLVM] packages ready to be installed with minimal impact on the distribution.
Packages are available for amd64 and i386 (except for recent Ubuntu) and for both the stable, old-stable and development branches (currently 8, 9 and 10).
Packages are built using stage2 and extremely similar to the one shipping in Debian & Ubuntu.
To use:
Add the appropriate repositories to the /etc/apt/sources.list file; there are distinct repos for different Debian and Ubuntu versions.
Add the apt key (shown in the link).
Run an apt update to refresh the cache.
Add packages with apt install clang-9 (or other package as desired).
If something "did not work" using the vetted package system, diagnose that issue directly. Xenial has Clang/LLVM 9 packages, and I've recently installed the packages into Disco.
The described symptom ("Unable to locate package") sounds as though one neglected to run apt update, in which case the packages from the newly-added sources would not be visible to apt. This is a tool-usage issue, not a lack of available packages.
LLVM INSTALLATION STEPS
-----------------------
LLVM Compiler Prerequisites:
OPERATING SYSTEM : Ubuntu 16.04 LTS
RAM : Minimum 16GB to 32GB
SWAP MEMORY : Minimum 10GB to 20GB
MEMORY NEEDED : Minimum 70GB
Install CMake version 3.5.1:
$sudo apt install cmake
LLVM Compiler Installation Steps
Step1:
#download llvm from https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/llvm-8.0.1.src.tar.xz
#download clang from https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/cfe-8.0.1.src.tar.xz
#extract files into folders:
tar -xf cfe-8.0.1.src.tar.xz
tar -xf llvm-8.0.1.src.tar.xz
#change directory names to llvm8 and clang
mv cfe-8.0.1.src clang
mv llvm-8.0.1.src llvm8
Step2 : #change present working directory to llvm_source_directory here it is llvm8
$cd llvm8
##create build directory
$mkdir build
##change pwd to build directory
$cd build
#Build (PATH =/llvm8/build)
#execute following command in build directory:
$cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../
Step3: #execute make command in pwd:
/llvm8/build$ make
Step4 : #after 100% of linking process execute following command in build directory:
$sudo make install
$ sudo reboot
step5 : #after installation restart your system!
#for checking llvm installation type
$llvm-config --version #it shows 8.0.1
$clang --version #it shows 8.0.1
Here are the commands for LLVM 9:
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo apt-get update
sudo apt-get install clang-9 libclang-9-dev llvm-9-dev

C++ Travis CI and Qt5

I am trying to configure my project on GitHub using continuous integration and would like to use Travis CI to do so. However, I am getting a build error with the current configuration of my travis.yml. My project uses Qt5, SQLite, and is in C++.
This is the yml:
language: cpp
compiler: gcc
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq sqlite3 qt5-dev-tools
before_script:
- mkdir build
- cd build
- cmake
script: make
I am new to this and I tried reading up on the documentation on their site, but I'm still having an issue understanding it. If anyone has an example, I would greatly appreciate it. OS is Windows.
Error:
make: *** No targets specified and no makefile found. Stop.
The command "make && make test" exited with 2.
I'd say that CMake has a non-intuitive error reporting here:
before_script:
- mkdir build
- cd build
- cmake
It returns success, although it hasn't configured anything in the build/ directory because it didn't know where the sources are.
Try cmake .. instead. Or cmake <your source directory>

How do you install Boost on MacOS?

How do you install Boost on MacOS?
Right now I can't find bjam for the Mac.
You can get the latest version of Boost by using Homebrew.
brew install boost.
Download MacPorts, and run the following command:
sudo port install boost
Just get the source, and compile Boost yourself; it has become very easy. Here is an example for the current version of Boost on the current macOS as of this writing:
Download the the .tar.gz from https://www.boost.org/users/download/#live
Unpack and go into the directory:tar -xzf boost_1_50_0.tar.gz
cd boost_1_50_0
Configure (and build bjam):
./bootstrap.sh --prefix=/some/dir/you/would/like/to/prefix
Build:
./b2
Install:./b2 install
Depending on the prefix you choose in Step 3, you might need to sudo Step 5, if the script tries copy files to a protected location.
Unless your compiler is different than the one supplied with the Mac XCode Dev tools, just follow the instructions in section 5.1 of Getting Started Guide for Unix Variants. The configuration and building of the latest source couldn't be easier, and it took all about about 1 minute to configure and 10 minutes to compile.
Install both of them using homebrew separately.
brew install boost
brew install bjam
Fink appears to have a full set of Boost packages...
With fink installed and running just do
fink install boost1.35.nopython
at the terminal and accept the dependencies it insists on. Or use
fink list boost
to get a list of different packages that are availible.
Install Xcode from the mac app store.
Then use the command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
the above will install homebrew and allow you to use brew in terminal
then just use command :
brew install boost
which would then install the boost libraries to <your macusername>/usr/local/Cellar/boost
In order to avoid troubles compiling third party libraries that need boost installed in your system, run this:
sudo port install boost +universal
Try +universal
One thing to note: in order for that to make a difference you need to have built python with +universal, if you haven't or you're not sure you can just rebuild python +universal. This applies to both brew as well as macports.
$ brew reinstall python
$ brew install boost
OR
$ sudo port -f uninstall python
$ sudo port install python +universal
$ sudo port install boost +universal
you can download bjam for OSX (or any other OS) here
If you are too lazy like me:
conda install -c conda-forge boost