1

I have installed Boost.Numpy on Boost 1.54 (libboost-all-dev) on Ubuntu 14.04.

This version of Numpy installs the library in a structure that you can invoke it like this in C++:

#include <boost/numpy.hpp>

Newer version of Boost (i.e., Boost 1.64+) which comes with Numpy preinstalled, uses a different structure that has the format of:

#include <boost/python/numpy.hpp>

It seems that having Boost.Numpy on Boost 1.58 is not compatible with code that assumes Numpy is installed through a newer version of Boost (i.e., boost/python/numpy.hpp).

I have some code, let's say package A, (that for some reason does not work with Boost 1.64) that uses Boost 1.54 and some other software, let's say package B, that I build from source that requires Boost with Numpy (and their code assume boost/python/numpy.hpp).

I would like to make this two compatible so I can only think of two solutions:

  1. Modify every code in the package B and change the definition #include <boost/python/numpy.hpp> to become <#include <boost/numpy.hpp> (although I am not sure if this will fix 100% the problem)
  2. Move all the Numpy files from my system from where they are to boost/python so they are compatible with package B (since package A does not need Numpy).

I am not sure if the two solutions will be appropriate or if there is a better way to do this? I am currently on a clean install and I don't want to break anything.

Unfortunately, I also tried to build package B with Boost 1.64 and package A with Boost 1.54 but the two are talking to each other and I found out that having the two with different Boost versions causes segmentation fault, so I definitely need to avoid this solution.

Phrixus
  • 333
  • 2
    I do not have 14.04 LTS to test your approach. But I see that 18.04 LTS has this functionality out-the-box. Do you plan to upgrade the Ubuntu to 18.04 LTS? It would be hassle-free solution. – N0rbert Jul 22 '18 at 11:22
  • @N0rbert You are right. Unfortunately, this is not an option, I am working with a specific stack of software that are currently working perfectly only with 14.04. – Phrixus Jul 22 '18 at 11:45
  • With reference to your previous question Boost.Numpy installed from source but is not working are you sure the issue is not that you are linking your software against the "wrong" libboost? (The accepted answer there would only address location of the correct headers, during the compilation phase - you likely need to use a -L directive to make sure it links against the libraries in /usr/local/lib). – steeldriver Jul 22 '18 at 13:25
  • I am not sure if I understood your point, but I don't think so, the code I am trying to compile has some files in src/ that have includes <#include <boost/python/numpy.hpp>. – Phrixus Jul 22 '18 at 13:35
  • @John is the thing you are trying to compile an executable program or a shared library? do you understand the difference between compiling and linking? if it's an executable, then what boost numpy library to you see if you run ldd on the executable after building it (in particular, is it the one in /usr/local or one in /usr/lib/x86_64-linux-gnu for example?) – steeldriver Jul 22 '18 at 14:57
  • It is a shared library. I use cmake and make. I thought this is compiling? – Phrixus Jul 22 '18 at 16:52

1 Answers1

1

As you do not want to upgrade to 18.04 LTS, so let's stay on 14.04 LTS.
But create Ubuntu 18.04 LTS schroot in it with new Boost here:

sudo apt-get install schroot debootstrap -y

cat <<EOF | sudo tee /etc/schroot/chroot.d/bionic.conf
[bionic]
description=Ubuntu 18.04
directory=/srv/chroot/bionic
root-users=$USER
type=directory
users=$USER
EOF

sudo mkdir -p /srv/chroot/bionic
sudo debootstrap bionic /srv/chroot/bionic

cat <<EOF | sudo tee /srv/chroot/bionic/etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
EOF

schroot -c bionic -u root apt-get update
schroot -c bionic -u root apt-get install software-properties-common sudo
schroot -c bionic -u root apt-get install libboost1.65-dev

Do not forget to change root to this chroot when you want to compile Boost-NumPy stuff:

schroot -c bionic

After this command the command prompt will change from user@host:~$ to (bionic)user@host:~$ and you can run compilation inside this shell.

I previously tested this method with other applications.
Currently I have 12.04 LTS (now EOL) schroot inside my 16.04 LTS for some development tasks.

N0rbert
  • 99,918
  • That is amazing! Is that possible? Let me try it on my VM and I will get back to you. (it will take a while) – Phrixus Jul 22 '18 at 12:02
  • 1
    Yes, it is possible. Do not forget to make snapshot (if it is production VM) :) – N0rbert Jul 22 '18 at 12:03
  • Will this require though to enter schroot -c bionic when I want to run the compiled code? Or the code will be compiled on my 14.04? – Phrixus Jul 22 '18 at 12:26
  • You need to enter to this new virtual environment with schroot -c bionic to have 18.04 LTS tools working. Also you can try to change directory to the code (for example ~/code - cd ~/code) and then run schroot -c bionic make here. – N0rbert Jul 22 '18 at 12:28
  • That is a small problem, because the library I would like to compile with libboost1.65 needs to talk with other libraries that are installed on 14.04 – Phrixus Jul 22 '18 at 12:30
  • Then you can try to install these libraries to 18.04 chroot with schroot -c bionic -u root apt-get install library-package-name. – N0rbert Jul 22 '18 at 12:31
  • I see. I don't think this will work, because these libraries are only available on 14.04 and compiled from source (robotics software mess) – Phrixus Jul 22 '18 at 12:32
  • There are to many constrains :) But I have no more ideas. – N0rbert Jul 22 '18 at 12:34
  • 1
    I know. Thanks so much for your time though! This schroot thing is really useful in general! – Phrixus Jul 22 '18 at 12:35