c++ - eclipse g++ not mangling function name -
a c++ module i'm working contains function (fitspectrumnaiu) calls 2 other functions (quadcal , mrqmin), , prototypes called functions included after first line of containing function:
/*++ analyze spectral data */ int fitspectrumnaiu(long inumchans, long *pspectrum, double dgain, double dzero, double *dcentroid, double *dfwhm, double *darea, double *derror) { double quadcal(double ax, double ay, double bx, double by, double cx, double cy); int mrqmin(double *x,double *y,double *sig,int npt,double *a,int *ia, int ma, double **covar, double **alpha, double *chisq, void (*funcs)(double, double*, double*, double*, int), double *alamda); ... (body of fitspectrumnaiu)
mrqmin() , quadcal() defined later on in source file.
the code compiles fine , becomes part of library subsequently linked main routine. problem occurs during linking eclipse g++ however. mrqmin() routine’s name not mangled when put archive , linker not find it. objdump of library, grep mrqmin (showing function definition – there static declarations appear, mangled), looks this:
00000000 *und* 00000000 _z6mrqminpds_s_is_piips_s1_s_pfvds_s_s_ies_ 000058c0 g f .text 00000a24 mrqmin
there’s mangled version of function name that’s expect , shown referenced undefined, while unmangled version of name marked defined. @ first thought there must extern c statement somewhere causing this, that's not case.
i expect mrqmin , quadcal handled identically, there no real definitional difference between them in code, quadcal appears name mangled in archive (below) , found linker:
00009068 g f .text 000002f0 _z7quadcaldddddd
eclipse version 3.3.0 , cdt 4.0.1.x , i'm constrained use these versions. links in same form under vs2012, , i’m not sure try next. ideas?
it sounds mrqmin declared extern "c" when it's compiled , in @ least 1 declaration. causes compiler function should use c style linkage, includes not mangling it.
i'm not sure why vs 2012 doesn't exhibit same problem, might have sort of header inclusion order. run source file of both it's compiled , it's used through preprocessor in g++ (using -e) , vs2012 (not sure how), , see if extern "c" present in both.
Comments
Post a Comment