Incomplete mangling of the GDCM OpenJPEG library

I recently found that your mangling of the OpenJPEG is incomplete. There are two OpenJPEG libraries in ITK:

  1. ITK\Modules\ThirdParty\OpenJPEG\src\openjpeg
  2. ITK\Modules\ThirdParty\GDCM\src\gdcm\Utilities\gdcmopenjpeg\src\lib\openjp2

The first one is an older version of OpenJPEG and appears mangled correctly. The second one from GDCM does miss a lot of functions to be mangled. We are linking against our own production version of the OpenJPEG and getting the following link errors (below).

Could you please re-mangled this library for the next maintenance release (4.13.2) and ITK 5?

Here is the list of my linking errors:

itkgdcmopenjp2-4.13.lib(image.obj) : error LNK2005: opj_image_create0 already defined ...
itkgdcmopenjp2-4.13.lib(image.obj) : error LNK2005: opj_image_comp_header_update already defined ...
itkgdcmopenjp2-4.13.lib(image.obj) : error LNK2005: opj_copy_image_header already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_write_bytes_BE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_read_bytes_BE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_write_bytes_LE already defined ... 
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_read_bytes_LE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_write_double_LE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_write_double_BE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_read_double_LE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_read_double_BE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_read_float_LE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_read_float_BE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_write_float_LE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_write_float_BE already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_read_data already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_write_data already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_flush already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_skip already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_tell already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_get_number_byte_left already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_write_skip already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_read_skip already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_read_seek already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_write_seek already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_seek already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_has_seek already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_default_read already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_default_write already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_default_skip already defined ...
itkgdcmopenjp2-4.13.lib(cio.obj) : error LNK2005: opj_stream_default_seek already defined ...
2 Likes

If I remember correctly, @mathieu.malaterre is the maintainer of GDCM.

Until mangling is updated, you can configure ITK to use system GDCM, which you compile yourself. And when configuring that, enable GDCM_USE_SYSTEM_OPENJPEG and point to your own version of OpenJPEG.

1 Like

I wonder if any particular reasons to have outdated version in ITK\src\Modules\ThirdParty\OpenJPEG? Should it be at least up to the GDCM version or latest 2.3.0? Then we could directly use it.

Updating the OpenJPEG version is a good idea, but it is unlikely to happen in the near future unless a patch is contributed; there are many other higher priority maintenance tasks.

When updated, it is best to start using the update third party Git subtree bash script:

This greatly reduces the burden of future updates.

@mathieu.malaterre, @matt.mccormick, @dzenanz Please review this patch, from me and @denis.p.shamonin: COMP: Fixed GDCM OpenJPEG name mangling

It would be great if this issue could still be fixed with ITK 5.0 :grinning:

2 Likes