ubuntu: including boost to eclipse CDT when installed from Aptitude - c++

I am new to both C++ and eclipse and I am trying to use smart pointers.
I installed boost using aptitude:
sudo apt-get install libboost-all-dev
then in my eclipse project I added "boost" to
/ properties / c/c++build / settings / cross G++ linker / Libraries /
now in my C++ I try to include smart pointers:
#include <boost/smart_ptr.h>
but I am told : unresolved inclusion: boost/smart_ptr.h
I am really not sure why. From my (limited) understanding, I should not need to look for the path to to the libboost and to the include path of the compiler. I based this on the fact that I included other libraries installed by aptitude and I could include them in my code directly.
Sounds like a basic question, but all the threads I could find were either about windows, or about boost being downloaded and manually compiled (in which case I understand the path has to be given to the compiler).
Anything I am missing ?
Thx a lot

Related

How to use FLANN installed from synaptic

I tried to compile FLANN with cmake, but the only result was a giant headache.
So I found here this solution through PCL repository and synaptic. The installation seems gone well, but now I don't know how to use the installed package.
Quoting FLANN's documentations :
An example of the compile command that must be used will look
something like this: g++ flann_example.cpp -I $FLANN_ROOT/include -o flann_example_cpp where $FLANN ROOT
is the library main directory.
But it's not clear to me where $FLANN_ROOT is.
The $FLANN_ROOT is a path where the library was installed. This is mostly relevant when you build and install manually (especially when installing to non-standard locations).
When installed by the packaging system (Synaptic - I guess Ubuntu?) the library headers will be most likely installed in '/usr/include' or '/usr/local/include'. Normally you do not have to use the -I then as those paths are examined by default.

linking boost filesystem and boost iostream libraries in ubuntu 14.04

I downloaded boost 1.61 and extracted it at /usr/local/boost_1_61_0 and while installing i set the prefix path to /usr/local/ where all the boost libraries are installed. I am trying to install FRESCO tool for DNA data compression which is built using Boost c++ libraries (Downloaded from https://github.com/hubsw/FRESCO). They have given make utility to install FRESCO tool.
But when I try to run make, I get errors regarding BOOST:FILESYSTEM and BOOST:IOSTREAM libraries as follows
undefined reference to `boost::iostreams::detail::gzip_header::reset()'
undefined reference to boost::iostreams::detail::zlib_base::~zlib_base()'
undefined reference to `boost::filesystem::detail::create_directories(boost::filesystem::path const&, boost::system::error_code*)'
and many more related to boost iostream and filesystem.
In FRESCO they mentioned they require BOOST 1.51(later), boost filesystem,boost iostream, boost threading-mt.
Can someone please suggest me where I am going wrong? How to link the boost filesystem/iostream if i am using make utility of ubuntu to install FRESCO tool?
I'm trying to compile boost as dependency for my project and I get similar errors.
I see two issues for your case:
I don't use FRESCO, but from its makefile I see -lboost_system -lboost_filesystem -lboost_iostreams, so it expects a global Boost installation. You don't need to compile Boost for that, you can use the packaged versions of your system. In ubuntu they can be installed with sudo apt-get install libboost-dev libboost-filesystem-dev libboost-iostreams-dev.
If you really want to compile Boost, that error message is about a part of boost that needs extra configuration for compiling it (compression filters). It tries to link to an object with some definitions that are not compiled by default (It would probably link correctly if FRESCO didn't use compression filters). Assuming that you are compiling with Boost.Build, for Boost.Iostreams this issue is explained (not very well IMO) in https://www.boost.org/doc/libs/1_61_0/libs/iostreams/doc/installation.html :
To build with Boost.Build, run bjam from the directory libs/iostreams/build, or from the Boost root directory. If you want to use the compression filters, you may need to set several Boost.Build variables indicating where the source files or pre-built binaries are located.
EDIT
There are other alternatives to compile Boost.Iostreams:
If you have installed bzip and zlib in the system, Boost.Build autoconfigures the compilation of those compression filters. In ubuntu, do sudo apt-get install libbz2-dev zlib1g-dev (in xenial, I haven't checked if the names are different in other versions).
If you can't install zlib and libbgzip in the system, and you compiled them yourself, put this in a file tools/build/src/user-config.jam inside the downloaded folder of boost:
using zlib : 1.2.11 : <include>/path-to-your-compilation/zlib-1.2.11 <search>/path-to-your-compilation/zlib-1.2.11 ;
using bzip2 : 1.0.6 : <include>/path-to-your-compilation/bzip2-1.0.6 <search>/path-to-your-compilation/bzip2-1.0.6 ;
Just replace path-to-your-compilation.
Then, do ./bootstrap.sh --with-libraries=filesystem,iostreams and ./b2.
Documentation for this (notice I'm using Boost 1.65):
user-config.jam: https://www.boost.org/doc/libs/1_65_1/doc/html/bbv2/reference.html#bbv2.reference.tools.libraries.zlib
general Boost install: https://www.boost.org/doc/libs/1_65_1/more/getting_started/unix-variants.html#prepare-to-use-a-boost-library-binary

Install GMP library on Mac OS X 10.9 and Xcode

My question is as simple as the title. I have a Macbook Pro with OS X Mavericks (10.9.4) and Xcode (5.1.1). I need to install the GMP arbitrary precision libraries so that I can just get to write GMP-enabled programs from within Xcode.
I downloaded the package from the official website
I extracted it to my desktop
./configure --prefix=/usr/local --enable-cxx
make
make check
sudo make install
But when I go to Xcode and just #include <gmpxx.h> it doesn't find it. Also adding -lgmp to my linker flags causes an error.
I also tried using homebrew with brew install gmp but that didn't work either (same symptohms)
What is the correct way to solve this problem?
You need to ensure that you have an include path -I/usr/local/include, before you can include <gmpxx.h> (or <gmp.h> for that matter).
Also, adding -lgmp is insufficient, since that's only the C interface. You want to link with -lgmpxx (the C++ library), and possible specify the path to that library with -L/usr/local/lib.
You can run otool -L /usr/local/lib/libgmpxx.dylib, to ensure that libgmp.dylib is already linked to it. Which it should be.
Set the Header Search Path and Library Search Path in the Xcode Project Settings to /usr/local/include and /usr/local/lib respectively as, by default, these paths are not searched by Xcode.

Installed Cygwin64 and cannot find unresolved inclusion in <iostream> when in eclipse

I linked to as many of the libraries as I can find and still I get an unresolved inclusion for <iostream> in eclipse. I even searched the c:\cygwin\ directory for iostream and I cannot find it. So, how do I find this basic library in the cygwin64 installation?
The default installation for Cygwin is quite minimal. In particular, it doesn't include software development tools.
Re-run the Cygwin setup.exe program and add gcc-g++ to your system. (It is in the Devel category on the Select Packages screen.) This will add the C++ compiler and Standard C++ library.

Build Boost on Mac with Xcode

I've recently got acquainted with Boost library and I'd like to use it in my Xcode project. But sadly there is no HowTo or FAQ on how to do it :(
What's the sequence of actions to build and use Boost libraries in Xcode?
The easiest way I've found to do it is to install MacPorts, then you can install/build Boost via a single command:
sudo port install boost
Plus you get similar access to other open source software. The only downside I've found is that, like any other package management system, they are not always up to date with the latest version.
If you prefer Homebrew as your package manager, the command is:
brew install boost
I don't know how to use Boost from XCode (I'm not a Mac programmer), but building boost is usually done through their own build tool, bjam.
They have a guide to building boost here, and you can download the latest version of bjam here
Once it is built, you reference it from Xcode the same way you would any other library. The boost/include should be added to your include path, and the libraries in boost/lib can be referenced for the boost libs that require it.
To build boost on a mac, follow the unix variants getting started page (http://www.boost.org/doc/libs/1_39_0/more/getting_started/unix-variants.html). You won't use Xcode directly to perform the build, but once complete you can add the boost include paths and dylib's to your Xcode project.
I found that to build Boost 1.41.1 on MacOS, you need to do the following:
Download boost 1.46.1 from here: http://sourceforge.net/projects/boost/files/boost/1.46.1/
Unpack the file
Open terminal, cd to the install directory, and do the following:
chmod u+x configure.sh
cd tools/build/v2/engine/src
chmod u+x build.sh
Then go back to the install directory, and:
./configure.sh
If that runs successfully, it will tell you to run:
./bjam
That's it.. for whatever reason, I needed to set those permissions manually before it would work.
su - root
enter root password and then run below as root
/opt/local/bin/port install boost
If you have never logged in as root or forgotten your password, here are the steps to reset root password
http://support.apple.com/kb/HT1528?viewlocale=en_US&locale=en_US
For most of the boost libraries, there's nothing to build, it's all in header files.
The remainder of the instructions are here.
Currently I'm very happy with using Pete Goodliffe's script which builds a framework from the Boost source package for both iOS and Mac. Drag and drop it into a project and it works!
There are multiple versions of the script out there. Here's one:
https://gist.github.com/faithfracture/c629ae4c7168216a9856/61be257e1c0839c85743777d0687becad9913bf7
Elaboration of Ferrucio's answer:
Install Boost using MacPorts (sudo port install boost) or Homebrew (brew install boost).
Find the path to the Boost header files (it should be in /opt/homebrew/include if you're using Homebrew).
Add the path to System Header Search Paths in the Build Settings of your Xcode target.
IMPORTANT NOTE: If you add the path to User Header Search Paths instead of System Header Search Paths, as other users suggested, then your code will fail to build, since the Boost files use angled-includes (#include <boost/filename.hpp>) to include each other. Angled-includes are only for including system library headers, and thus they only work if Boost is in the System Header Search Paths.
You can read about the difference between angled-includes and quoted-includes here.