Domanda

I got a new installation of Ubuntu 11.10 and kernel version 3.0.0-23-generic and +/- by default I get the following version 1.46.1 of Boost which is installed under /usr/include/boost and /usr/lib:

bravegag@Zeus:~/code/roofline/tool$ dpkg --get-selections | grep boost
libboost-date-time1.46.1        install
libboost-dev                    install
libboost-iostreams1.46.1        install
libboost-program-options1.46.1  install
libboost-serialization1.46.1    install
libboost-thread1.46.1           install
libboost1.46-dev                install

I could try updating it by the standard Ubuntu means but this will most likely imply I need to get some third party ppa and pull as side effect lot of crap that will make my system unstable and I do not want that. So I installed Boost 1.50 from source and it was installed under /usr/local/include/boost and /usr/local/lib.

A CMake project I have picks up the 1.50 version no problems. However, a tool I am using that compiles and links using the "default" system settings ends up picking the 1.46.1 version and results in the error message src/utils.h:17:25: error: ‘boost::BOOST_FOREACH’ has not been declared so obviously is not picking the 1.50 version.

I tried overwriting the default g++/gcc Boost version like this:

export CPLUS_INCLUDE_PATH=/usr/local/include/boost/:$CPLUS_INCLUDE_PATH   
export LIBRARY_PATH=/usr/local/lib/:$LIBRARY_PATH

but this doesn't do the trick either ... my question is can I not simply sweep out all those old Boost 1.46 installations and move over to the default /usr/include and /usr/lib the 1.50 installation? would doing this cause my system to break? I don't want to risk another re-installation spree.

È stato utile?

Soluzione

I could try updating it by the standard Ubuntu means but this will most likely imply I need to get some third party ppa and pull as side effect lot of crap that will make my system unstable

You can add a PPA, install only the packages you want and (if the PPA contains more than just the Boost libraries) remove it, so that no other package will get auto-updated. I think that's the easiest way to go.

However, a tool I am using that compiles and links using the "default" system settings ends up picking the 1.46.1

What kind of tool is it? Maybe you can configure it to use Boost from a custom location? If it's gcc-based, making it pass -I and -L flags to the compiler and linker might help.

can I not simply sweep out all those old Boost 1.46 installations and move over to the default /usr/include and /usr/lib the 1.50 installation? would doing this cause my system to break?

In most GNU/Linux distributions (with Ubuntu among them) the /usr prefix is reserved for software managed with the distribution's package manager. Installing a non-packaged software there will work at first, but you may have some trouble (e.g. package manager complaints) when some package will actually contain the same files. That's why for manually compiled, non-packaged software it's a common practice to use other prefixes like /usr/local or /opt/something.

Most shared libraries are versioned, so it is safe to have multiple versions of them installed on the same system at the same time. Particularly, you can have multiple versions of Boost runtime packages in Ubuntu. If you still want to make a manual install of Boost to /usr, you don't have to remove the old Boost runtime version, which is good if you found out that some important software packages depend on them.

However, before installing your newly compiled Boost to /usr, firstly remove from your system all *boost*dev packages (and all other *dev packages that depend on them), because they contain the header files (many Boost components are header-only), static libraries and symbolic links to particular runtime libraries version.

To confirm that it works, I just compiled and installed Boost 1.51 to /usr on my Ubuntu 11.04 using this method and nothing broke. Aptitude still uses Boost 1.42:

$ ldd /usr/bin/aptitude | grep boost
libboost_iostreams.so.1.42.0 => /usr/lib/libboost_iostreams.so.1.42.0 (0x00007f536ee77000)

And newly compiled programs use the new version:

$ g++ my-boost-test.c -lboost_thread -o my-boost-test
$ ldd my-boost-test | grep boost
libboost_thread.so.1.51.0 => /usr/lib/libboost_thread.so.1.51.0 (0x00007f543d1df000)
libboost_chrono.so.1.51.0 => /usr/lib/libboost_chrono.so.1.51.0 (0x00007f543c49e000)
libboost_system.so.1.51.0 => /usr/lib/libboost_system.so.1.51.0 (0x00007f543c29a000)

Altri suggerimenti

Your question of

my question is can I not simply sweep out all those old Boost 1.46 installations and move over to the default /usr/include and /usr/lib the 1.50 installation? would doing this cause my system to break? I don't want to risk another re-installation spree.

gets a clear Yes it could as there are plenty of reverse dependencies between packages, and the hence a dependence on the particular version. Eg on my Ubuntu system (which got upgraded several times)

edd@max:~$ dpkg -l | grep libboost-date-time | cut -c-72
ii  libboost-date-time-dev                        1.48.0.2              
rc  libboost-date-time1.38.0                      1.38.0-6ubuntu6       
ii  libboost-date-time1.40.0                      1.40.0-6ubuntu1       
rc  libboost-date-time1.42.0                      1.42.0-4ubuntu2       
ii  libboost-date-time1.46-dev                    1.46.1-7ubuntu3       
ii  libboost-date-time1.46.1                      1.46.1-7ubuntu3       
edd@max:~$ 

We see that 1.38 and 1.42 were fully replaced, but there are other packages still depending on 1.40 as well as 1.46, even though my development version is now 1.48.

So your best best is to ... get 1.50 or even 1.51 from a PPA if such a version exists, or to install into /usr/local and to adjust your makefile / configure / cmake / ... settings accordingly.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top