[gdal-dev] How can you use GDAL from a process that has already loaded some other app's xerces-c_2_7.dll?

Jason Roberts jason.roberts at duke.edu
Tue Dec 30 11:51:59 EST 2008


With the 1.6 release, GDAL for win32 appears to have taken a new dependency
on xerces-c_2_7.dll. Unfortunately this causes compatibility problems with
other applications.

An increasing number of apps and programming environments rely on xerces-c,
including MATLAB and ArcGIS. The windows releases of MATLAB 2007b, 2008a,
and 2008b and ArcGIS 9.3 all compile their own copies of xerces-c_2_7.dll.
Because they used a different compiler and/or build options than GDAL, their
copies of xerces-c_2_7.dll are incompatible with GDAL (and each other). I am
writing programs that need to load both MATLAB and GDAL into the same
process. Somehow I have to get the MATLAB DLLs to load and link to the
MATLAB version of xerces-c_2_7.dll, and gdal16.dll to load and link to
GDAL's version of xerces-c_2_7.dll. How can I do this?

One attempt looks like this:

1. As recommended by MATLAB, add MATLAB directories to the PATH.
2. As recommended by MATLAB, use load-time dynamic linking to link to MATLAB
DLLs. When my program runs it loads MATLAB's xerces-c_2_7.dll.
3. Try to explicitly load GDAL by calling
LoadLibrary("C:\\gdalwin32-1.6\\bin\gdal16.dll"). This fails with
0xC0000139: Entry Point Not Found.

I have tried setting the PATH by calling SetEnvironmentVariable prior to
step 3. It appears that LoadLibrary checks "do I already have a DLL named
xerces-c_2_7.dll loaded?" and uses it without caring about where it is
located or rechecking the PATH.

Any idea how to get this done?

Ideally, every app that compiles its own xerces-c_2_7.dll should either give
it a private name or leverage the Windows side-by-side (sxs) infrastructure.
Because everybody is using it, you could say xerces-c_2_7.dll now has
equivalent status to libraries such as MSVCRT. Any chance that GDAL could
employ one of these solutions so that it may be called from programs that
also load ArcGIS 9.3 or MATLAB DLLs?

Thanks for looking at this,

Jason




More information about the gdal-dev mailing list