Re: [AMBER] AMBER CUDA Installation

From: Jason Swails <>
Date: Fri, 22 Nov 2013 07:32:18 -0500

On Fri, 2013-11-22 at 12:38 +0100, Massimiliano Porrini wrote:
> Hi all,
> I just wanted to add my contribute to the following topic
> (also to know if I have done the correct thing):
> I had exactly the same error message while compiling serial CUDA-enabled
> pmemd of Amber12.
> My soft/hard -ware settings are as follow:
> - Ubuntu 13.04 (raring)
> - gcc 4.7.3
> - Nvidia driver version: 304.88
> - 1 Tesla K20c
> Just following Scott Le Grand's advice, I added "-lstdc++" to the
> LDFLAGS of the config.h file located in $AMBERHOME/AmberTools/src/ ,
> to be more specific:
> and this allowed to me to successfully build the executable pmemd.cuda ,
> which in turn successfully passed all the test cases.
> I would be pleased to know if I proceeded in the correct way though
> (which apparently worked fine).

Yes, this is the correct approach. A more extensive explanation is
provided in the postscript for those interested.



The longer explanation has to do with the subtle differences between
linking and compiling. The distinction is roughly this: Compiling turns
source code into machine code (.o object files, for instance). Linking
combines a bunch of compiled machine code (of which libraries are an
example) into an executable that you can run. Modern compilers can do
both (in the same command). Naturally, the C++ compiler will
automatically search through the standard C++ library (-lstdc++) to
resolve any necessary symbols, but you would not necessarily expect the
Fortran compiler to do the same thing.

pmemd.cuda is a mixed C(++)/Fortran code (obviously with some CUDA C
thrown in). The Fortran code is compiled with a Fortran compiler, the
CUDA code is compiled with nvcc, and the C++ code is compiled with a C++
compiler (or a C compiler that supports the C++ features being used).
The linking stage, however, is done with the Fortran compiler, so it is
not necessarily surprising that the standard C++ library is not provided
automatically by that linker. When libstdc++ is not added
automatically, the appropriate solution is to provide it explicitly to
the linker. This is an implementation detail of the compiler suite, so
the safest thing to do (and the approach adopted for the next release of
Amber) is to always provide -lstdc++ to the linker line.

Jason M. Swails
Rutgers University
Postdoctoral Researcher
AMBER mailing list
Received on Fri Nov 22 2013 - 05:00:02 PST
Custom Search