Opened 6 years ago

Closed 6 years ago

#4144 closed enhancement (fixed)

Add capability to safely link against an external libtiff (3.X) and a GDAL build with internal libtiff (4.0) support

Reported by: rouault Owned by: rouault
Priority: normal Milestone: 1.9.0
Component: ConfigBuild Version: unspecified
Severity: normal Keywords: libtiff libgeotiff internal
Cc:

Description (last modified by rouault)

Currently it is not safe for an application to link libgdal built with internal libtiff support with system libtiff (3.X), because of the difference of ABI. The same issue could potentially happen with libgeotiff (in 1.9.0dev trunk, it's at v1.3.0, whereas in the wild you mostly find it at v1.2.0).

The solution implemented consists in :

  • compiling a libtiff.so/libgeotiff.so,
  • extracting the symbols from the .so with objdump,
  • and creating a header file that does #define original_symbol_name gdal_original_symbol_name for each symbol.

This process is automated by a dump_symbols.sh scripts in frmts/gtiff/libtiff and frmts/gtiff/libgeotiff that must be run whenever internal libtiff/libgeotiff is updated (and that the version includes new symbols). The generated files are placed in svn to avoid running the script at each build, mainly because the script might only work on Linux. Wouldn't work as it on MacOS. But the end-result should be portable.

Of course, one also must make sure this header file is included at the appropriate places. This mainly consists in including it in the tif_config.h and geo_config.h, but also in the INGR, NITF, JPEG drivers happen to use libtiff symbols, and MrSID for libgeotiff.

The renaming of the symbols is enabled if --with-rename-internal-libtiff-symbols is defined. (--with-rename-internal-libgeotiff-symbols for geotiff).

This can be combined with the --with-hide-internal-symbols of course so that those gdal_ prefixed symbols are not exported, but this is an orthogonal issue.

Change History (6)

comment:1 Changed 6 years ago by rouault

r22639 /trunk/gdal/ (19 files in 8 dirs): Add --with-rename-internal-libtiff-symbols and --with-rename-internal-libgeotiff-symbols configure flags in order to safely link against an external libtiff (3.X) and a GDAL build with internal libtiff (4.0) support (#4144)

r22640 /trunk/gdal/frmts/aigrid/aigccitt.c: Rename symbols to make checking the use of libtiff symbols easier. Not strictly necessary, but makes life easier (#4144)

comment:2 Changed 6 years ago by rouault

  • Description modified (diff)

comment:3 Changed 6 years ago by rouault

  • Description modified (diff)

comment:4 Changed 6 years ago by rouault

  • Description modified (diff)

comment:5 Changed 6 years ago by rouault

  • Description modified (diff)

comment:6 Changed 6 years ago by rouault

  • Keywords libtiff libgeotiff internal added
  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.