[gdal-dev] CPLFindFile not honoring CPLSetConfigOption

Even Rouault even.rouault at spatialys.com
Tue Aug 24 14:26:40 PDT 2021


Christopher,

CPLFindFile() calls CPLFinderInit() which issues CPLGetConfigOption( 
"GDAL_DATA", nullptr). But CPLFinderInit() runs once per-thread. So a 
potential theory for what you observe would be that something runs 
CPLFindFile() before you call CPLSetConfigOption("GDAL_DATA", ...). 
Setting breakpoint on CPLFinderInit and CPLSetConfigOption should 
confirm if this is what actually happens

Even

Le 24/08/2021 à 23:17, Christopher Corbell a écrit :
> I'm tracking down a bug with WFS data import in our app and it seems 
> like the cause is a call to CPLFindFile returning NULL, looking for a 
> gmlasconf.xml file that should be in the gdal share directory.
>
> This is a Mac universal binary app that embeds GDAL as a dylib and 
> also includes the share files, so we use 
> CPLSetConfigOption("GDAL_DATA", ...) to configure the CPL. So we don't 
> rely on any absolute install/build paths or on the end-user installing 
> their own GDAL. This worked previously but we recently updated to GDAL 
> 3.3.1.
>
> The WFS import fails when CPLFindFile returns NULL on attempt to read 
> that config file, but the bug does not occur on my workstation, where 
> this copy of GDAL was built. It turns out this is because CPLFindFile 
> will return the original location of the GDAL build/install share 
> directory (which still exists on my system).
>
> Can anyone offer a theory why CPLFindFile might ignore the gdal data 
> path and only look in the absolute install path set when GDAL was 
> built? Here's some debugger output showing how these functions point 
> to two different directories at runtime:
>
> (lldb) po (const char*) CPLGetConfigOption("GDAL_DATA")
> "/Users/ccorbell/Development/working/ccorbell_27x_MBP/IP Source/Plug-ins/Common/Data/GIS/gdal/"
>
> (lldb) po (const char*) CPLFindFile("gdal", "gmlasconf.xml")
> "/Users/ccorbell/Development/working/ccorbell_27x_MBP/AppSource/ThirdPartySource/GDAL/config/gdal-3.3.1-x86_64/share/gdal/gmlasconf.xml"
>
> Thanks,
> Christopher
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210824/d0dc7648/attachment.html>


More information about the gdal-dev mailing list