[mpich-discuss] Undefined references to MPL, seems to be caused by --if-needed
Jed Brown
jed at 59A2.org
Thu Nov 18 11:08:37 CST 2010
MPICH2 1.3.1:
$ cat cxx.C
#include <mpi.h>
int main(int argc,char *argv[])
{
MPI_Comm comm;
MPI::Init(argc,argv);
MPI::Finalize();
return 0;
}
$ /opt/mpich2/bin/mpicxx cxx.C
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trfree'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_env2str'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trlevel'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trvalid'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trmalloc'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trspace'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_env2range'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trcalloc'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_env2int'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trdump'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_env2bool'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trstrdup'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trrealloc'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_TrSetMaxMem'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trinit'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trDebugLevel'
/opt/mpich2/lib/libmpich.so: undefined reference to `MPL_trid'
collect2: ld returned 1 exit status
$ /opt/mpich2/bin/mpicxx -show cxx.C
c++ -Wl,--hash-style=gnu -Wl,--as-needed cxx.C -I/opt/mpich2/include
-L/opt/mpich2/lib -Wl,-rpath -Wl,/opt/mpich2/lib -lmpichcxx -lmpich -lopa
-lmpl -lpthread -lrt
$ c++ -Wl,--hash-style=gnu cxx.C -I/opt/mpich2/include -L/opt/mpich2/lib
-Wl,-rpath -Wl,/opt/mpich2/lib -lmpichcxx -lmpich -Wl,--as-needed -lopa
-lmpl -lpthread -lrt
$ ./a.out
It's not clear to me why the symbols in libmpich.so are not being marked as
needed. This does not happen when compiling C programs (with mpicc or
mpicxx). It's possible that it is a linker bug, but I have not seen this
issue with any other packages. Perhaps it's a circular reference.
c++ (GCC) 4.5.1
GNU ld (GNU Binutils) 2.20.1.20100521
These link errors aside, I think it is incorrect for MPICH to include
user-specified libraries in the --as-needed sequence:
$ /opt/mpich2/bin/mpicxx -show cxx.C -lfoo
c++ -Wl,--hash-style=gnu -Wl,--as-needed cxx.C -lfoo -I/opt/mpich2/include
-L/opt/mpich2/lib -Wl,-rpath -Wl,/opt/mpich2/lib -lmpichcxx -lmpich -lopa
-lmpl -lpthread -lrt
I think the --as-needed should only come after the last of the user's
parameters (they may turn it on, but it shouldn't be on by default for their
libraries).
Jed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20101118/74db5991/attachment.htm>
More information about the mpich-discuss
mailing list