Re: error loading cxx local model in isis: undefined symbol

From: John Houck <houck_at_email.domain.hidden>
Date: Tue, 19 Nov 2013 05:44:46 -0500
On Mon, Nov 18, 2013 at 12:56 -0500, Maurice Leutenegger wrote:
> Thomas,
>
> I just tried your test example with the most recent versions of isis
> and heasoft, and I get the same error. I ran nm on the local models
> library and I do not see a function name C_test or c_test - I only
> have _test.
>
> Note that I am using OS X 10.8 - I think you are using linux? But we
> are getting the same error.
>
> John, any idea of what is going wrong? Have the XSPEC developers
> changed the interface to the local models libraries again?

I think it's just a matter of providing an additional
subroutine for a C interface.

For example, have a look at how xspec provides C and Fortran
interfaces for the xspec internal models. See, e.g.
 heasoft-6.14/Xspec/src/XSFunctions/funcWrappers.cxx

For a C++ local model that provides a symbol 'test':

   extern "C"
   void test(const RealArray& energy,
             const RealArray& parameter,
             int spectrum,
             RealArray& flux,
             RealArray& fluxError,
             const string& init)

the lmodel.dat file should, by convention, refer to subroutine
C_test.

The notation "C_test" means that a C++ interface is provided
through the symbol "test", while a C interface (if it exists)
should appear under the name "C_test".

Following the examples in funcWrappers.cxx, a C-linkage symbol
C_test can be defined as in the appended code segment.

Once this C-linkage symbol is provided, libxspeclocal.so will
contain two symbols through which the local model can be
evaluated. C++ programs can call 'test' and C programs can call
'C_test'.

If you also want to provide a Fortran linkage symbol, then
funcWrappers.cxx shows one way to do that via cfortran.h. One
could also use the iso_c_binding module with "modern" Fortran.

Thanks,
-John

// Here's an example C-linkage wrapper definition for 'test'.
// An implementation of cppModelWrapper is in funcWrappers.cxx
// mentioned above.

extern "C"
void C_test (const double* energy, int nFlux, const double* params,
          int spectrumNumber, double* flux, double* fluxError, const char* initStr)
{
   const size_t nPar = 3;
   cppModelWrapper(energy, nFlux, params, spectrumNumber, flux, fluxError,
                   initStr, nPar, test);
}

----
You received this message because you are
subscribed to the isis-users list.
To unsubscribe, send a message to
isis-users-request_at_email.domain.hiddenwith the first line of the message as:
unsubscribe
Received on Tue Nov 19 2013 - 05:45:10 EST

This archive was generated by hypermail 2.3.0 : Fri May 02 2014 - 08:35:47 EDT