Building Boost 1.46.1 *with openmpi*?
Question: I would like to build all of the [Boost](http://www.boost.org/) library on
Ubuntu 11.04 with gcc 4.5.2. So I went about downloading the tar.bz2 file. I
expanded it. I ran bootstrap.sh and noticed it complaining about unicode, so I
installed:

`sudo apt-get install libicu-dev`

And now it appears to be happily building with unicode. The trouble is that I
want to also link against OpenMPI. uh oh. So I add `using mpi ;` to
`./tools/build/v2/user-config.jam` and ran my build command:

`./bjam --layout=versioned --build-type=complete`

And boost prints out errors(I've abbreviated the large paragraphs):

    
    
    error: Duplicate name of actual target: <pstage/lib>mpi.so
    error: previous virtual target { common%common.copy-mpi.so.PYTHON_EXTENSION {
    

... then a few pages ...

    
    
    error: created from ./stage-proper
    error: another virtual target { common%common.copy-mpi.so.PYTHON_EXTENSION {
    

... then a few more pages ...

    
    
    error: created from ./stage-proper
    error: added properties: <debug-symbols>off <define>NDEBUG <inlining>full <library>object(file-target)@3501 <library>object(file-target)@3568 <library>object(file-target)@4171 <library>object(file-target)@4184 <library>object(searched-lib-target)@4066 <library>object(searched-lib-target)@4072 <library>object(searched-lib-target)@4078 <optimization>speed <runtime-debugging>off <variant>release <xdll-path>/home/mtibbits/src/boost_1_46_1/bin.v2/libs/mpi/build/gcc-4.5.2/release/threading-multi <xdll-path>/home/mtibbits/src/boost_1_46_1/bin.v2/libs/python/build/gcc-4.5.2/release/threading-multi <xdll-path>/home/mtibbits/src/boost_1_46_1/bin.v2/libs/serialization/build/gcc-4.5.2/release/threading-multi
    error: removed properties: <debug-symbols>on <inlining>off <library>object(file-target)@1244 <library>object(file-target)@1350 <library>object(file-target)@2378 <library>object(file-target)@2393 <library>object(searched-lib-target)@2217 <library>object(searched-lib-target)@2223 <library>object(searched-lib-target)@2229 <optimization>off <runtime-debugging>on <variant>debug <xdll-path>/home/mtibbits/src/boost_1_46_1/bin.v2/libs/mpi/build/gcc-4.5.2/debug/threading-multi <xdll-path>/home/mtibbits/src/boost_1_46_1/bin.v2/libs/python/build/gcc-4.5.2/debug/threading-multi <xdll-path>/home/mtibbits/src/boost_1_46_1/bin.v2/libs/serialization/build/gcc-4.5.2/debug/threading-multi
    /home/mtibbits/src/boost_1_46_1/tools/build/v2/build/virtual-target.jam:490: in actualize-no-scanner from module object(file-target)@4661
    /home/mtibbits/src/boost_1_46_1/tools/build/v2/build/virtual-target.jam:135: in object(file-target)@4661.actualize from module object(file-target)@4661
    /home/mtibbits/src/boost_1_46_1/tools/build/v2/build-system.jam:748: in load from module build-system
    /home/mtibbits/src/boost_1_46_1/tools/build/v2/kernel/modules.jam:283: in import from module modules
    /home/mtibbits/src/boost_1_46_1/tools/build/v2/kernel/bootstrap.jam:142: in boost-build from module
    /home/mtibbits/src/boost_1_46_1/boost-build.jam:17: in module scope from module
    

It appears to be a [bug](https://svn.boost.org/trac/boost/ticket/3560) dating
back to Boost 1.40?? But I know others have gotten this to work. Does anyone
know the voodoo required to get Boost 1.46.1 to play nice with openmpi?

Note: I've been googling and this doesn't appear to be an Ubuntu specific
problem -- it has appeared on
[gentoo](https://bugs.gentoo.org/show_bug.cgi?id=329207) and elsewhere. But I
haven't found any concrete solution except _build without mpi..._ which I
can't.

I would happily post the entire logs, package versions, etc.


Answer: from some other forum, I found that in /tools/build/CMake/externals, there
should be a MPI.cmake file. adding the following lines should allow you to
build Boost with OpenMPI:

    
    
    set(MPI_INCLUDE_PATH /usr/include/openmpi-x86_64)
    set(MPI_COMPILE_FLAGS -I/usr/include/openmpi-x86_64)
    set(MPI_LINK_FLAGS -L/usr/lib64/openmpi/lib -L/usr/lib64/openmpi/lib/openmpi
    -lmpi_cxx -lmpi)
    set(MPI_LIBRARIES /usr/lib64/openmpi/lib/libmpi.so
    /usr/lib64/openmpi/lib/libmpi_cxx.so)
    set(MPI_FOUND 1)
    

