Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

March 15, 2006

Installing C++ Boost on Gentoo and Debian/Ubuntu

Filed under: C++ Boost, GNU/Linux, Gentoo, Ubuntu — tabrez @ 4:00 pm

Note: Updated the post to note the availability of C++ Boost 1.34.1 libraries for Gentoo and (especially) for Ubuntu 7.10(Gutsy Gibbon).

1. C++ Boost on Gentoo:

On the shell prompt, type:

sh# emerge boost

This should install the latest version of boost available for Gentoo. Currently 1.33.1 version of Boost Libraries is available for Gentoo. Synchronise(’emerge –sync’) with the Gentoo portage if your ‘emerge -p boost’ shows an earlier version. You can install the latest version Boost 1.34.1 by adding the line “dev-libs/boost ~x86″ to “/etc/portage/package.keywords” file.

2. C++ Boost on Debian/Ubuntu:

Update2:
Boost 1.34.1 version is now available. To install the latest version, run the following command(or select these packages from Synaptic Package Manager):
sh# apt-get   install   libboost-date-time-dev libboost-date-time1.34.1   libboost-dev   libboost-doc   libboost-filesystem-dev   libboost-filesystem1.34.1   libboost-graph-dev   libboost-graph1.34.1   libboost-iostreams-dev   libboost-iostreams1.34.1 libboost-program-options-dev   libboost-program-options1.34.1   libboost-python-dev   libboost-python1.34.1   libboost-regex-dev   libboost-regex1.34.1   libboost-signals-dev   libboost-signals1.34.1   libboost-test-dev   libboost-test1.34.1   libboost-thread-dev   libboost-thread1.34.1  

Or,

sh# apt-get install libboost.*-dev libboost-doc libboost.*1.34.1
Update1: See the new update above
Boost 1.33.1 version is now available. To install this version, run the following command(or select these packages from Synaptic Package Manager):
sh# apt-get   install   libboost-date-time-dev libboost-date-time1.33.1   libboost-dev   libboost-doc   libboost-filesystem-dev   libboost-filesystem1.33.1   libboost-graph-dev   libboost-graph1.33.1   libboost-iostreams-dev   libboost-iostreams1.33.1 libboost-program-options-dev   libboost-program-options1.33.1   libboost-python-dev   libboost-python1.33.1   libboost-regex-dev   libboost-regex1.33.1   libboost-signals-dev   libboost-signals1.33.1   libboost-test-dev   libboost-test1.33.1   libboost-thread-dev   libboost-thread1.33.1  

Or,

sh# apt-get install libboost.*-dev libboost-doc libboost.*1.33.1
Run the following command(or select these packages from Synaptic Package Manager): See the update above
sh# apt-get   install   libboost-date-time-dev libboost-date-time1.33.0   libboost-dev   libboost-doc   libboost-filesystem-dev   libboost-filesystem1.33.0   libboost-graph-dev   libboost-graph1.33.0   libboost-iostreams-dev   libboost-iostreams1.33.0 libboost-program-options-dev   libboost-program-options1.33.0   libboost-python-dev   libboost-python1.33.0   libboost-regex-dev   libboost-regex1.33.0   libboost-signals-dev   libboost-signals1.33.0   libboost-test-dev   libboost-test1.33.0   libboost-thread-dev   libboost-thread1.33.0  

You can use the following simple command to install every library present in Boost that matches the pattern, if you don’t want to be selective about which libraries to install:

sh# apt-get install libboost.*-dev libboost-doc libboost.*1.33.0

All this mess could be avoided if only Debian/Ubuntu packages could build a meta-package to include all the C++ Boost libraries. One could use the pattern libboost.* but it includes the Boost debug files(libboost-dbg) too.

3. Build C++ Programs Using Boost Libraries

Once the boost package is installed, the C++ programs that make use of boost libraries can be built simply like this:

sh# g++ -o first first.cpp

If the program needs to be linked to a library(for eg: filesystem library), then specify the name of the library using the -l switch:

sh# g++ -o second second.cpp -lboost-filesystem

I will follow this up with the installation procedure for Slackware and RPM based distributions(Done).


Update:Thanks to Jun Zhang for pointing out the missing packages in the Boost installation command for Ubuntu; the command is now updated.


If you want to receive future posts by email, enter your email address here:

Related Posts:

8 Comments »

In Ubuntu, the above steps will not install any header files into the system. Then, the following test compiling will also be failed.

Please using the following command:
apt-get install libboost.*dev

Quote

Comment by Jun Zhang — August 21, 2006 @ 9:44 am

Yes, you are right. Thanks for catching the goof-up and letting me know about it.
The post is now fixed to incorporate the necessary changes.

Cheers.

Quote

Comment by tabrez — September 11, 2006 @ 6:15 pm

When it says
sh# g++ -o second second.cpp -lboost-filesystem
I had to use
sh# g++ -o second second.cpp -lboost_filesystem
[using an underscore instead]

Quote

Comment by Auryn — October 17, 2006 @ 8:22 pm

The option to be passed to the g++ compiler depends on the name of the library that is installed on a particular platform. It’s different on different GNU/Linux distributions, for example:

-lboost_filesystem for Gentoo/Fedora/SUSE
-lboost_filesystem-gcc for Slackware/Zenwalk

I use any one of them in the example code with the assumption that it will be replaced by whatever actual name is used on a particular distribution.

Quote

Comment by tabrez — October 18, 2006 @ 5:11 pm

Thanks a million! I used your instructions on a Knoppix 5 HD install after failing to be able to use the ‘long way’ (Synaptics PM retrieved boost-build v2 and bjam, but they refused to install v1.3.1 off sourceforge).

Only the apt-get on the boost python lib gave me trouble. I don’t need it, so I omitted it.

Anyway - hats off to you.

Quote

Comment by JOanzi — December 2, 2006 @ 5:04 am

I use kubuntu 6.06. I tried every options. I also enable every repostories. But won’t work. Any ideas? Thanks.

Quote

Comment by PLMoe — March 4, 2007 @ 9:38 am

Here is the error

plmoe@kubuntu:~$ g++ -o first first.cpp
first.cpp:8:2: warning: no newline at end of file
plmoe@kubuntu:~$ g++ -o second second.cpp -lboost_filesystem
second.cpp:2:42: error: boost/filesystem/operations.hpp: No such file or directory
second.cpp:9:2: warning: no newline at end of file
second.cpp:3: error: ‘boost’ has not been declared
second.cpp:3: error: ‘filesystem’ is not a namespace-name
second.cpp:3: error: expected namespace-name before ‘;’ token
second.cpp: In function ‘int main()’:
second.cpp:6: error: ‘bfs’ has not been declared
second.cpp:6: error: ‘path’ was not declared in this scope
second.cpp:6: error: expected `;’ before ‘p’
second.cpp:7: error: ‘bfs’ has not been declared
second.cpp:7: error: ‘p’ was not declared in this scope
second.cpp:7: error: ‘exists’ was not declared in this scope

Quote

Comment by PLMoe — March 4, 2007 @ 9:48 am

[...] How to Test C++ Boost InstallationC++ Boost Filesystem Library(Part III): Example ProgramsInstalling C++ Boost on Slackware/ZenwalkBoost Filesystem Library: Writing Portable C++ Programs to Acess The FilesystemInstalling C++ Boost on Gentoo and Debian/Ubuntu [...]

Quote

Pingback by Every Flavour Beans » C++ Boost Filesystem Library(Part II): Example Programs — May 13, 2007 @ 10:47 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

Subscribe without commenting


Copyright (c) 2006, 2007 Tabrez Iqbal.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


Powered by WordPress
This website is hosted by Dreamhost


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser
Mobilytics