[Trilinos-Users] Not able to load shared library, undefined symbol in Trilinos

Hoemmen, Mark mhoemme at sandia.gov
Fri Jun 27 12:08:57 MDT 2014


On 6/27/14, 12:00 PM, "trilinos-users-request at software.sandia.gov"
<trilinos-users-request at software.sandia.gov> wrote:
>Message: 1
>Date: Thu, 26 Jun 2014 18:14:02 +0000
>From: "Lo, Chaomei" <c.lo at pnnl.gov>
>To: David Hysom <hysom1 at llnl.gov>,
>	"trilinos-users at software.sandia.gov"
>	<trilinos-users at software.sandia.gov>
>Subject: Re: [Trilinos-Users] [EXTERNAL]  Not able to load shared
>	library, undefined symbol in Trilinos
>Message-ID:
>	<D6B4208069E7224F8B3C2BA6897777F720203448 at EX10MBOX05.pnnl.gov>
>Content-Type: text/plain; charset="us-ascii"
>
>This is an interesting circle of community - when I sent this request, I
>did not know David - the developer of the code.
>
>Ok. I will do David suggested. However, I found the fix but I do not
>understand why, that is - if the type of the global index is defined as
>"long", the this "undefined symbol" occurs when I load the shared library
>generated from R. If the type is "int" then it does not have problem.
>Also I noticed that in the code the this Tpetra::CrsMatrix has only four
>template parameter (see the matrix_t type defined in below), but it
>actually has five as the document specified.  I am not sure if this was
>another problem.
>
>" Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node,
>LocalMatOps >"
>
>typedef Tpetra::CrsMatrix<scalar_t, local_ordinal_t, global_ordinal_t,
>node_t>   matrix_t;
>
>Thanks,
>Chaomei

Hi Chaomei -- I am a Tpetra developer.  Remember that templated C++
classes don't actually exist until they are used or instantiated (unless
you enabled explicit template instantiation (ETI) in the Trilinos build).
Thus, the Tpetra library doesn't actually contain code for
Tpetra::CrsMatrix.  That would explain why the linker can't find it.  It
has nothing to do with the fifth template parameter of CrsMatrix, which
you can ignore in practice.

If you want to call Tpetra::CrsMatrix methods from R (or C, or Fortran, or
any language other than C++), you have two options:

  1. Enable ETI when building Trilinos.  (ETI is off by default.)
  2. Do explicit instantiation yourself.

#1 is really easy: When running CMake to configure Trilinos, set the
following CMake configuration option:

  Trilinos_ENABLE_EXPLICIT_INSTANTIATION:BOOL=ON

Tpetra has macros to help you with #2.  Note that #1 will only help you
with CrsMatrix methods that themselves are not templated.  Templated
methods of a templated class don't get explicitly instantiated (this is
why they live in the _decl files, not in the _def files).

mfh



More information about the Trilinos-Users mailing list