| 1 | == What is vsipreload? == |
| 2 | |
| 3 | vsipreload is a library included with gdal which can be used to extend [[UserDocs/ReadInZip]] functionality to non-VSI-aware programs. |
| 4 | |
| 5 | It works by using the dynamic linker's `LD_PRELOAD` system to override certain libc function calls with GDAL equivalents. |
| 6 | |
| 7 | vsipreload currently only works on Linux. |
| 8 | |
| 9 | |
| 10 | == Building vsipreload == |
| 11 | |
| 12 | 1. Build GDAL configured with `--with-pic` |
| 13 | 2. |
| 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 | |
| 20 | Some notes: |
| 21 | |
| 22 | 1. 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 | |
| 24 | 2. (1) requires libgdal to be configured `--with-pic`, otherwise the static linking doesn't work. |
| 25 | |
| 26 | 3. debhelper/lintian seems to dislike libraries without sonames. You might be able to skip this step; YMMV. |
| 27 | |
| 28 | |
| 29 | == Using vsipreload == |
| 30 | |
| 31 | Just 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 |
| 35 | poly.dbf poly.PRJ poly.shp poly.shx |
| 36 | }}} |