Hi Thomas, here is the code. You can invoke the wrapper function like this: #include "isisCPPFunctionWrapper.h" static const size_t MYXSPECMODEL_N_PARAMETERS (anIntegerConstant); // This is the number of parameters in your model as specified in lmodel.dat void myXSPECmodel (const RealArray& energy, const RealArray& parameter, int spectrum, RealArray& flux, RealArray& fluxError, const string& init) { ... } void myXSPECmodel_isis (const Real* energy, int Nflux, const Real* parameter, int spectrum, Real* flux, Real* fluxError, const char* init) { isisCPPFunctionWrapper (energy, Nflux, parameter, spectrum, flux, fluxError, init, MYXSPECMODEL_N_PARAMETERS, &myXSPECmodel); return; } Cheers, Maurice On 11/14/13 4:12 PM, Thomas Dauser wrote: > Hi Maurice, > > yes, what you describe is exactly my problem. It would be great if you > could send me your source code of the wrapper. > > Thanks! > > Cheers, > Thomas > > On 11/14/2013 04:03 PM, Maurice Leutenegger wrote: >> Hi Thomas, >> >> if you have declared your XSPEC local model function prototypes as "C++ >> style", i.e. using RealArray&s instead of Real*s, then you won't be able >> to use them even if the "extern C" linkage problem is fixed, since the >> function explicitly includes C++ objects in the interface to isis. I >> solved this problem by writing a wrapper function and then using the >> wrapper to create an isis alias function for each of my local models, >> e.g. myLocalModel (C++ inputs)-> myLocalModel_isis (C inputs). If this >> is useful to you, let me know and I will send you the source code for >> the wrapper. >> >> Cheers, >> >> Maurice >> >> >> On 11/14/13 3:45 PM, John Houck wrote: >>> On Wed, Nov 13, 2013 at 15:07 -0500, Thomas Dauser wrote: >>>> Dear isis-users, >>>> >>>> did anyone experience problems including a cxx local model in isis? >>>> >>>> Here is my problem: I compile it once with xspec: >>>> >>>> initpackage fun_test lmodel.dat . >>>> >>>> While I can load (and evaluate) it in xspec without errors: >>>> >>>> XSPEC12>lmod fun_test . >>>> Model package fun_test successfully loaded. >>>> >>>> however, for the same model library (without any recompiling), isis >>>> complains with >>>> >>>> isis> load_xspec_local_models ("."); >>>> Loading ././libfun_test.so >>>> Error loading symbol C_test for model fun >>>> Link error: ././libfun_test.so: undefined symbol: C_test >>>> >>>> And isis is somehow right, as C_test is not defined ("nm -D >>>> libfun_test.so | grep C_test" does not give a result). >>> Since isis is (usually compiled as) a C program and not a C++ >>> program, your model must export a "C" linkage symbol for isis >>> to link to. >>> >>> What output does this produce?: >>> nm libfun_test.so >>> >>> The C++ symbols are usually "mangled" containing embedded >>> interface that describes the subroutine interface. >>> Probably your library contains only a C++ interface. >>> >>> To provide a C-linkage symbol, your C++ interface must >>> provide an interface declared as extern "C" (and that also >>> follows the Xspec interface naming conventions). >>> >>> Thanks, >>> -John >>> >>>> What am I missing here? Is there a difference, how I need to treat >>>> xspec and isis local models? I know that the "C_" has to be included >>>> in the lmodel.dat file to tell xspec/isis that this is C/C++ code >>>> and not fortran. >>>> >>>> I have the latest isis version 1.6.2-27 and heasoft 6.14 installed. >>>> >>>> Thanks for your help. >>>> >>>> Cheers, >>>> Thomas >>>> >>>> ---- >>>> 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.hidden>>>> with the first line of the message as: >>>> unsubscribe >>> ---- >>> 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.hidden>>> with the first line of the message as: >>> unsubscribe >>> >> >> ---- >> 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.hidden>> with the first line of the message as: >> unsubscribe >> ---- 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
This archive was generated by hypermail 2.3.0 : Fri May 02 2014 - 08:35:47 EDT