How do you install Boost on MacOS? - c++

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

Related

How can I install boost multiprecision library in ubuntu

I installed boost library in my ubuntu 12.04 machine using the following command:
sudo apt-get install libboost-all-dev
But when I checked /usr/include/boost, I don't see header files for multiprecision package (cpp_dec_float.hpp). Do I need to install it separately?
Boost.Multiprecission is present in Boost 1.53 onwards.
http://www.boost.org/doc/libs/1_53_0/libs/multiprecision/doc/html/boost_multiprecision/map/hist.html
If you install libboost-all-dev metapackage from precise repository by dependncy you get libboost-dev and by dependncy you also get libboost1.46-dev which is unfortunately too old.
http://packages.ubuntu.com/precise/libboost-all-dev
http://packages.ubuntu.com/precise/libboost-dev
http://packages.ubuntu.com/precise/libboost1.46-dev
You might try your luck with some PPA repository.
E. g. this one:
https://launchpad.net/~apokluda/+archive/ubuntu/boost1.53
and install the package following this tutorial.
https://charmie11.wordpress.com/2013/10/27/install-boost-1-53-on-ubuntu-by-package-manager/

Poco/Data/SQLite/Connector.h: No Such file or directory

Asked a similar question recently but trying to simplify it since no one have been able to help.
I'm trying to compile a c++ program and I keep getting the error that it can't find Poco/Data/SQLite/Connector.h.
using: #include "Poco/Data/SQLite/Connector.h"
I've ran about a dozen installs trying to get this to work including:
sudo apt-get install openssl libssl-dev
sudo apt-get install libiodbc2 libiodbc2-dev
sudo apt-get install libpoco-dev
sudo gmake -s install under the downloaded libpoco dir.
I even see src/connector.cpp installed with the last.
New to C++ and Linux (raspbian on the pi 2), but can't seem to get the code to find this library.
Any suggestions?
In case anyone else has this issue.
libmysqlclient-dev needs to be installed first for these libraries to get installed with the poco install. Just doing mysql-client doesn't do it.
Change your path "Poco/Data/SQLite/Connector.h" to "Poco/Data/SQLite/connector.h". Hope this will help.

OpenCV GTK+2.x error - "Unspecified error (The function is not implemented...)"

I had installed OpenCV following these steps. After trying to compile one example, I got this error:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/nick/.Apps/opencv/modules/highgui/src/window.cpp, line 516
terminate called after throwing an instance of 'cv::Exception'
what(): /home/nick/.Apps/opencv/modules/highgui/src/window.cpp:516: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.4)
project(threadTest)
find_package( OpenCV REQUIRED )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pthread")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "/home/nick/ClionProjects/threadTest")
set(SOURCE_FILES main.cpp)
add_executable(threadTest ${SOURCE_FILES})
target_link_libraries( threadTest ${OpenCV_LIBS} )
How can I solve it?
First check whether libgtk2.0-dev is installed properly. If you have installed aptitude package manager, run the following:
sudo aptitude search libgtk2.0-dev
It should return like this:
i libgtk2.0-dev - development files for the GTK+ library
p libgtk2.0-dev:i386 - development files for the GTK+ library
You need to build the files once again. Locate your OpenCV folder. Create a new folder and name it Release. Enter into this folder. For example,
cd /home/user_name/OpenCv
mkdir Release
cd Release
Now build using CMake with following command:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..
Remember to put WITH_GTK=ON during CMake.
After this step, enter the command,
make
sudo make install
This should resolve your problem. If you have broken dependencies for libgtk2.0-dev, then install a fresh copy of libgtk2.0-dev using aptitude.
sudo aptitude install libgtk2.0-dev
If you installed OpenCV using the opencv-python pip package, be aware of the following note, taken from opencv-python:
IMPORTANT NOTE
macOS and Linux wheels have currently some limitations:
video related functionality is not supported (not compiled with FFmpeg)
for example cv2.imshow() will not work (not compiled with GTK+ 2.x or Carbon support)
Also note that to install from another source, first you must remove the opencv-python package.
To install OpenCV in Ubuntu, I followed this guide, and it worked perfectly fine: Ubuntu 16.04: How to install OpenCV
In order to improve Nic Szer's answer I want to explain how to fix this error on macOS in three simple steps.
Remove installed OpenCV version to avoid messing up later
pip3 uninstall opencv-python
Lower your Python version to 3.5 (the current version, 3.6, has problems with Conda which we will use to install OpenCV)
conda install python=3.5
Finally, use Conda to install a working version of OpenCV
conda install -c menpo opencv3
And then voilà: OpenCV will start working on your macOS (macOS v10.12.4 (Sierra)).
For Windows, just uninstall the OpenCV package:
pip uninstall opencv-python
And reinstall:
pip install opencv-python
In case what is mentioned in previous answers doesn't work, try:
pip install opencv-python
for Python 2, or
pip3 install opencv-python
for Python 3.
For me (Arch Linux, Anaconda with Python 3.6), installing from the suggested channels menpo or loopbio did not change anything. My solution was to
install pkg-config (sudo pacman -Syu pkg-config),
remove opencv from the environment (conda remove opencv) and
re-install opencv from the conda-forge channel (conda install -c conda-forge opencv)
conda list now returns opencv 3.3.0 py36_blas_openblas_203 [blas_openblas] conda-forgeand all windows launched using cv2 are working fine.
I have had to deal with this issue a couple of times, and this is what has worked consistently thus far:
conda remove opencv
conda install -c menpo opencv
pip install --upgrade pip
pip install opencv-contrib-python
I have the solved using Anaconda 3 installing on Ubuntu 16.04 (Xenial Xerus).
I have used the PyCharm editor for my Python code.
I am using the Python 3.6 version.
I solved the issue using these processes.
IDEA: we need to install the package opencv-contrib-python package from PyCharm.
After installing OpenCV using vcpkg on Ubuntu, there is a known issue with vcpkg where you'll end up with the exact same error message as the top of this post with no access to highgui:
OpenCV(4.3.0) Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support.
If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow,
file .../vcpkg/buildtrees/opencv4/src/4.3.0-0c6047baf6.clean/modules/highgui/src/window.cpp, line 634
Caught exception: OpenCV(4.3.0) .../vcpkg/buildtrees/opencv4/src/4.3.0-0c6047baf6.clean/modules/highgui/src/window.cpp:634:
error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support.
If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'
The problem is vcpkg passes in the build option -DWITH_GTK=OFF when building OpenCV. The open issue: https://github.com/microsoft/vcpkg/issues/12621
The workaround is the following:
edit the file vcpkg/ports/opencv4/portfile.cmake
find the line that says -DWITH_GTK=OFF and change it to say -DWITH_GTK=ON
run ./vcpkg remove opencv4
run sudo apt-get install libgtk2.0-dev pkg-config
reinstall OpenCV with ./vcpkg install opencv4 or whichever vcpkg command you used
I have Ubuntu 16.04 LTS (Xenial Xerus) environment with GTK 3 preinstalled.
I got the same error for Caffe build (master branch),
Try the following steps, may be it should work for you.
sudo apt-get install libgtk-3-dev
cmake .. (WITH_GTK=ON and other settings),
make
And bingo, the error was gone... in my Python Caffe code
Please note:
The CMake configuration should reflect GTK+ 3.x instead of GTK+ 2.x:
GUI:
-- QT: NO
-- GTK+ 3.x: YES (ver 3.18.9)
-- GThread : YES (ver 2.48.2)
-- GtkGlExt: NO
-- OpenGL support: NO
-- VTK support: NO
I have fixed my issue using this,try it
pip install opencv-python-headless==4.5.3.56
pip install opencv-contrib-python==4.5.3.56
pip install opencv-python==4.5.3.56
I had the same problem, and fixed it by simply reinstalling opencv.
There is no need to uninstall it first.
My issue was solved after installing opencv-contrib-python:
pip install opencv-contrib-python
I tried several of the previous answers the one that worked for me in ubuntu is mentioned in the following steps:
Firstly, remove the current opencv package that is installed in your system by typing in the following command in the terminal conda remove opencv.
If your Python version is 3.6 or above then change it into the stable version which can be done by typing in conda install python=3.5.
Later on, install the opencv package again by giving the following input in terminal conda install -c menpo opencv3
I had the same issue and it has been resolved after uninstalling opencv-python and doing a fresh install.
pip uninstall opencv-python
pip install opencv-python
try this. It worked for me
sudo apt-get install cmake cmake-curses-gui libgtk2.0-dev
pip install opencv-contrib-python
reinstalling and installing with the above command solved my issue but just after closing all instances of pyhton and anaconda because apparently a cache version of the library was being kept in my system.
Hence, uninstall opencv (try with pip and conda), close the IDE and reboot it, check if you can import opencv. If you still can import it, try to run the code:
help(cv2)
and check where the files are stored and delete that folder.
Repeat the process untill you are sure it is uninstalled so you can reinstall opencv full package (option 2 - see https://pypi.org/project/opencv-python/ )
I had the same issue and it has been resolved after uninstalling opencv-python version 4 and then installing the OpenCV version 3.
pip install opencv-python==3.4.9.33
I have fixed this issue by replacing
cvDestroyWindow("showImage");
by
cvDestroyWindow("ShowImage");

Install boost version 1.40

I am using a server running with Ubuntu 12.04
I want to install the boost libraries in it. I know
sudo apt-get install libboost-all-dev
will make the work done, but it installs the latest version version 1.52 or above.
But I need to install the particular version 1.40 as there is a problem in a simulator which I am using for my academic purpose. What is the particular command for that so that I can install the boost libraries along with the other requirements for it like the linking files
Thanks in advance
Quick answer: sudo apt-get install libboost-dev= 1.40.0.1
If it doesn't work, continue reading.
The apt-get does support installing a particular version of a package as long as it is in an archive that apt knows about. From the apt-get manpage:
A specific version of a package can be selected for installation by following the
package name with an equals and the version of the package to select. This will
cause that version to be located and selected for install. Alternatively a specific
distribution can be selected by following the package name with a slash and the version of
the distribution or the Archive name (stable, frozen, unstable).
For e.g. if you wanted to install apache 2.20 for Ubuntu, you would do something like:
sudo apt-get install apache2=2.2.20-1ubuntu1
Note that you may need to do some dependency resolution on your own in this case, but if there are any problems apt-get will tell you what is causing them. For e.g.(on 11.04)
sudo apt-get install apache2=2.2.20-1ubuntu1 \
apache2.2-common=2.2.20-1ubuntu1 \
apache2.2-bin=2.2.20-1ubuntu1 \
apache2-mpm-worker=2.2.20-1ubuntu1
Note: You must first check if build 1.40 is still available. For that use:
aptitude search libboost
If aptitude search command don't give you sufficient results, try sudo aptitude update and then run aptitude search again.
You might have to investigate whether debs from earlier Ubuntu versions can be installed. i.e. remove the current package, download the debs and try installing them. But there could be dependency on older versions of the standard library.If so, you can probably try downloading the source from launchpad.
As a last resort, download from boost.org and build it - painfully!
EDIT: I see you have asked the same question on ubuntu forums and it seems that you have 1.48 as the default. You might have to build the library itself. Can you try this apt-get
sudo apt-get install libboost1.40-all-dev=1.40.0-4ubuntu4
If this doesn't work, you will have to build it and install it yourself. You can download the source from
Download source (1.40.0): libboost 1.40.0 source files
After it's installed, run the following command to hold your installed version, preventing the package manager from automatically updating it in the future:
sudo echo "[packagename] hold" | sudo dpkg --set-selections
Source:How to Downgrade Packages on Ubuntu
Generally you download sources, build it (some parts are not just headers like filesystem on Windows). Then you can select which subset of libraries you want to install (you can make compact version with only what you need). Then by invoking bootstrap script you build it to another directory this subset of libraries you want and then you invoke install.
Here is a pretty good description how to do it: http://ubuntuforums.org/showthread.php?t=1180792

Not able to install GDB on Fedora

How to download and install GDB(GNU Debugger) on Fedora Linux Machine.. I have tried downloading from gnu website 7.1 package, but then it fails during
./configure and then make command...
Please share the source from where i can get information on the same.
Thanks..
I have found this tutorial which might be helpful to install gdb.
http://www.tutorialspoint.com/gnu_debugger/installing_gdb.htm
But for me the command:
yum install gdb
works.
You may need to install some development packages with header files needed to build gdb. The exact package list depends on error messages from ./configure and make. Here is installed package list on my system:
# rpm -qa "*devel"
kernel-devel-2.6.23.1-42.fc8
ncurses-devel-5.6-12.20070812.fc8
python-devel-2.5.1-15.fc8
expat-devel-2.0.1-2
libtirpc-devel-0.1.7-12.fc8
glibc-devel-2.7-2
libstdc++-devel-4.1.2-33
Try to install all of them with yum.