LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2003-05-08 06:36:41

On Thu, 8 May 2003, Jerome BENOIT wrote:

> > [snipped]
> Let me be concrete. I want to build a dynamic library which is mainly
> non MPI as a part of a MPI program. I guess it a good idea to use the
> regular C/C++ compiler to build this library and then compile the MPI
> program with mpicc/mpic++.

Why not compile the library with mpicc?

When *compiling*, mpicc will only add compiler flags (e.g., -I). When
*linking*, mpicc will add the relevant compiler and linker flags (e.g, -I,
-L, and -l). Hence, there's no need to worry about mpicc adding in the
MPI libraries when otherwise unrelated libraries.

However, if LAM was compiled to be thread safe (which it is by default),
then your library should be compiled to be thread safe as well. For
example, some gcc installations accept the "-pthread" flag, which mpicc
will then also use. Other examples include -D_REENTRANT, -mt, etc.
Specifically: mpicc will use the same thread flags that LAM was compiled

So it's a larger matter than just the include files -- even if we added
mpicc --showme-incdir, that's not enough. Hence, we'd really need to add
something like --showme-cflags. You'd probably use it like:

        cflags="`mpicc --showme-cflags`"
        $CC $cflags my_lib_file.c -c

...which is exactly the same as using mpicc to compile my_lib_file.c.

My point here is that mpicc is totally self-contained. There's no need to
extract what mpicc is doing and then have something else perform the exact
same actions.

{+} Jeff Squyres
{+} jsquyres_at_[hidden]