|
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
functions.
foo.exe ----calls----> bar.so ----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
LD_LIBRARY_PATH=/usr/local/mpich-1.2.5/lib:/home/tk/cvstop/DO/bin/tmp/libbar.so/gcc/debug/shared-linkable-true:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
"g++" -g -o "/home/tk/cvstop/DO/bin/tmp/foo/gcc/debug/foo"
-L"/usr/local/mpich-1.2.5/lib"
-L"/home/tk/cvstop/DO/bin/tmp/libbar.so/gcc/debug/shared-linkable-true"
"/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...
<unquote>
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)
toon
--------------060001070904010102020604 Content-Type: text/plain;
name="foo.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="foo.cpp"
#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;
name="bar.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="bar.cpp"
#include <mpi.h>
int bar()
{
int size ;
MPI_Comm_size( MPI_COMM_WORLD, &size ) ;
return size ;
}
--------------060001070904010102020604 Content-Type: text/plain;
name="Jamfile"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Jamfile"
project-root ;
dll bar
:
bar.cpp
:
<include>/usr/local/mpich-1.2.5/include
;
exe foo
:
foo.cpp
<dll>bar
:
<include>/usr/local/mpich-1.2.5/include
<library-path>/usr/local/mpich-1.2.5/lib
<find-library>mpich
<find-library>pmpich
;
--------------060001070904010102020604--
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk