Opened 20 years ago
Last modified 20 years ago
#668 closed defect (fixed)
On Darwin (MacOS X) systems CPLGetSymbol() may not find the symbol.
Reported by: | Owned by: | warmerdam | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | default | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: |
Description
On Mach-o based systems C symbols have a leading underscore and depending on how dlcompat is configured it may or may not add the leading underscore. I'm using gdal-1.2.0 on MacOS X.3.? with fink's dlcompat. I have not tried it with 10.3 version of dlcompat. Here is a patch that adds a leading underscore if dlsym fails. ====================== void *CPLGetSymbol( const char * pszLibrary, const char * pszSymbolName ) { void *pLibrary; void *pSymbol; pLibrary = dlopen(pszLibrary, RTLD_LAZY); if( pLibrary == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "%s", dlerror() ); return NULL; } pSymbol = dlsym( pLibrary, pszSymbolName ); #if (defined(__APPLE__) && defined(__MACH__)) /* On mach-o systems, C symbols have a leading underscore and depending * on how dlcompat is configured it may or may not add the leading * underscore. So if dlsym() fails add an underscore and try again. */ if( pSymbol == NULL ) { char withUnder[strlen(pszSymbolName) + 2]; withUnder[0] = '_'; withUnder[1] = 0; strcat(withUnder, pszSymbolName); pSymbol = dlsym( pLibrary, withUnder ); } #endif if( pSymbol == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "%s", dlerror() ); return NULL; } return( pSymbol ); } ======================
Note:
See TracTickets
for help on using tickets.