2

When dynamically linking a library is there a way to specify a fallback symbol in case one is missing at load time.

For example compiling a MEX file instead of mxCreateNumericArray I'd like to call mxCreateUninitNumericArray (with same signature). But the latter won't be present for older MATLAB versions. Same for mxArrayToString and mxArrayToUTF8String.

For MSVC I've been able to use /DELAYLOAD and hook into __pfnDliFailureHook2 on dliFailGetProc to provide a simple mapping. But what can I do on Unix based systems?

How to hook into libld in a similar way?

1 Answers1

2

I've not been able to hook into the dynamic linker, but providing weak symbols helped me out like this:

extern "C"
char * __attribute__ ((weak)) mxArrayToUTF8String( mxArray const * array )
{
  return mxArrayToString( array ) ;
}