Changes between Initial Version and Version 1 of VSIPreload


Ignore:
Timestamp:
May 25, 2015, 10:11:47 PM (9 years ago)
Author:
cdestigter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • VSIPreload

    v1 v1  
     1== What is vsipreload? ==
     2
     3vsipreload is a library included with gdal which can be used to extend [[UserDocs/ReadInZip]] functionality to non-VSI-aware programs.
     4
     5It works by using the dynamic linker's `LD_PRELOAD` system to override certain libc function calls with GDAL equivalents.
     6
     7vsipreload currently only works on Linux.
     8
     9
     10== Building vsipreload ==
     11
     121. Build GDAL configured with `--with-pic`
     132.
     14{{{
     15    g++ -Wl,-soname,libgdal_vsipreload.so.1 -Wall -fPIC port/vsipreload.cpp \
     16    -shared -o libgdal_vsipreload.so.1 -Iport -L. -L.libs \
     17    -Wl,-Bstatic -lgdal -Wl,-Bdynamic -ldl -lpthread -lcurl
     18}}}
     19
     20Some notes:
     21
     221. statically linked `-lgdal`. This means using `LD_PRELOAD` loads a fairly minimal symbol set, so conflicting symbols with libraries loaded later aren't a problem. Otherwise you may run into problems with conflicting symbols from the various GDAL dependencies. An example is the ESRI FileGDB API, which exports a lot of libxml symbols, and when preloaded it may cause segfaults in other code that uses libxml symbols.
     23
     242. (1) requires libgdal to be configured `--with-pic`, otherwise the static linking doesn't work.
     25
     263. debhelper/lintian seems to dislike libraries without sonames. You might be able to skip this step; YMMV.
     27
     28
     29== Using vsipreload ==
     30
     31Just put LD_PRELOAD before your executable, and add the necessary /vsi... path parts to what you're doing:
     32
     33{{{
     34$ LD_PRELOAD="/home/vagrant/host/c/gdal/libgdal_vsipreload.so.1" ls /vsizip/vsicurl/http://svn.osgeo.org/gdal/trunk/autotest/ogr/data/poly.zip
     35poly.dbf  poly.PRJ  poly.shp  poly.shx
     36}}}