LAM/MPI logo

LAM/MPI General User's Mailing List Archives

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

From: Camm Maguire (camm_at_[hidden])
Date: 2001-12-10 23:00:59


Greetings! The gcc suite >=3.0 requires linking in libstdc++ when
linking c++ objects. When the linker is called by the name 'c++' or
equiv., this happens automatically, just as libg2c.a is added when the
linker is invoked via f77/g77. Earlier gcc suites did not require the
-lstdc++, apparently. In any case, the wrapper compilers handle c++
fine, as they invoke c++, but for fortran and C they add -llammpi++ to
the command line, without the implicit -lstdc++, and this fails.

One easy solution is to just add -lstdc++ to LAM_SYSLIBS, or some
such. This is a bit ugly though for distributions, such as Debian,
which will have different default compilers on different
architectures. Surely we don't want the arbitrary overhead of
requiring everyone who compiles any mpi program in any language to
link in lammpi++, libstdc++, and have a working c++ setup, etc.

For hcc, there is a somewhat simple patch:

--- lam-6.5.6.orig/tools/hcc/hcc.c
+++ lam-6.5.6/tools/hcc/hcc.c
@@ -400,23 +400,27 @@
 #endif
 
 #if LAM_WANT_MPI2CPP
- found = check_file(plib + 2, "liblammpi++.a");
- if (found)
- fl_want_mpi2cpp = 1;
- else {
- found = check_file(plib + 2, "liblammpi++.so");
+ if (getenv("LAM_IS_COMPILING_CPP")!=0) {
+
+ found = check_file(plib + 2, "liblammpi++.a");
             if (found)
               fl_want_mpi2cpp = 1;
             else {
- fl_want_mpi2cpp = 0;
- if (!fl_building) {
- fprintf(stderr,
- "WARNING: %s expected to find liblammpi++.* in %s\n",
- argv[0], plib + 2);
- fprintf(stderr,
- "WARNING: MPI C++ API support will be disabled\n");
+ found = check_file(plib + 2, "liblammpi++.so");
+ if (found)
+ fl_want_mpi2cpp = 1;
+ else {
+ fl_want_mpi2cpp = 0;
+ if (!fl_building) {
+ fprintf(stderr,
+ "WARNING: %s expected to find liblammpi++.* in %s\n",
+ argv[0], plib + 2);
+ fprintf(stderr,
+ "WARNING: MPI C++ API support will be disabled\n");
+ }
               }
             }
+
           }
 #endif
         }

This assumes that one never wants to use gcc to link when one's code
has c++, which really makes sense. Likewise, the block in hf77.c
which adds in -llammpi++ can safely be commented out, to my
understanding. As the comment preceding it says, its only there for
the obscure case of calling c++ code from fortran. I really don't
even know if this is possible! In any case, I've put these two fixes
in the Debian package to close a bug as a temporary measure. I'd be
happy to implement whatever you guys think best.

Take care,

-- 
Camm Maguire			     			camm_at_[hidden]
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah
_______________________________________________
This list is archived at http://www.lam-mpi.org/MailArchives/lam/