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.
Related Posts:
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
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.
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]
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.
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.
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.
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
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 [...]
Pingback by Every Flavour Beans » C++ Boost Filesystem Library(Part II): Example Programs — May 13, 2007 @ 10:47 pm