Boost logo

Boost-Build :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2004-04-27 12:01:32

I have a dynamic library 'bar' that calls MPI routines (or whatever
third party library) that are defined in a static library. Now my
executable 'foo' calls a function defined in 'bar' and also calls MPI

foo.exe ----calls----> ----calls-----> MPI (mpich.a, pmpich.a)
| ^

Now when I ask bjam to link my executable (see Jamfile, foo.cpp and
bar.cpp in attachment), the static MPI library shows up in front of the
(dynamic) library 'bar':

<quote of output generated by 'bjam -d2>
...found 65 targets...
...updating 1 target...
gcc-Link-action /home/tk/cvstop/DO/bin/tmp/foo/gcc/debug/foo

set -e


"g++" -g -o "/home/tk/cvstop/DO/bin/tmp/foo/gcc/debug/foo"
"/home/tk/cvstop/DO/bin/tmp/foo/gcc/debug/foo.o" -lmpich -lpmpich
-lbar -Wl,-rpath-link,.

Chmod1 /home/tk/cvstop/DO/bin/tmp/foo/gcc/debug/foo

chmod 711 "/home/tk/cvstop/DO/bin/tmp/foo/gcc/debug/foo"

...updated 1 target...

Now I know that the order of the libraries for static libraries matters
and does not matter for shared libraries. However I'm not sure if the
order matters for a mix of static and shared libraries. But if I put the
(static) mpi library after 'bar' it links fine, if not, I have
undefineds in 'bar'.

So my question now is, should'nt libraries added in the requirements
section not always appear after the libraries in the source section of
the target description. The requirements section generally refers to
libraries from the system whereas the source-section refers to libraries
in your project which are possibly dependent on the system libraries.

(I hope I succeeding in communicating this thing clearly, I tried to
explain this as good as I can)

 --------------060001070904010102020604 Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

#include <iostream>
#include <mpi.h>

int bar() ;

int main(int argc, char* argv[])
MPI_Init( &argc, &argv ) ;
std::cout << bar() << std::endl ;
MPI_Finalize() ;
return 0 ;
 --------------060001070904010102020604 Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

#include <mpi.h>

int bar()
int size ;
MPI_Comm_size( MPI_COMM_WORLD, &size ) ;
return size ;
 --------------060001070904010102020604 Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

project-root ;

dll bar

exe foo

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at