# VTK master + ITK master = HDF5 duplicate symbol link errors

**URL:** https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290
**Category:** Engineering
**Created:** [September 13, 2018, 8:44pm UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290 "2018-09-13T20:44:35Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [September 13, 2018, 8:44pm UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290/1 "2018-09-13T20:44:35Z")

</div>

Hi all,

I’ve just tried building current VTK master + current ITK master then building my own app against them. The result is about 150 link errors, all along the lines of:

```auto
duplicate symbol _H5_libinit_g in:
    /path/to/ITK/lib/libitkhdf5_debug.a(H5.c.o)
    /path/to/VTK/lib/libvtkhdf5.a(H5.c.o)
duplicate symbol _H5_libterm_g in:
    /path/to/ITK/lib/libitkhdf5_debug.a(H5.c.o)
    /path/to/VTK/lib/libvtkhdf5.a(H5.c.o)

```

I checked a handful, and indeed they are in neither VTK’s nor ITK’s HDF mangling file. In addition, they all seem to be global variables (not functions).

This is on macOS, not sure if that matters.

If I run the command at the top of the ITK mangle file:

```auto
nm -g lib/libitkhdf5* 2> /dev/null | grep " [TDRS] " | awk '{ print substr($3, 2); }' | awk '{ sub(/itk_/, ""); print }' | sed 's/\(.*\)/#define \1\ itk_\1/' | sort -u

```

then my results include the “H5\_libinit\_g” symbol. OTOH, my results do _not_ include other symbols like “H5AC\_dxpl\_id”.

My results also include other symbols, ex “H5AC\_cache\_is\_clean”, that were removed by this commit (for some reason):

[http://review.source.kitware.com/#/c/23666/1/Modules/ThirdParty/HDF5/src/itkhdf5/src/itk\_hdf5\_mangle.h](http://review.source.kitware.com/#/c/23666/1/Modules/ThirdParty/HDF5/src/itkhdf5/src/itk_hdf5_mangle.h)

It seems that the proper/complete generation of this mangling file may require running on multiple platforms and taking the union of the results…

If I merge my results into what’s in ITK master, my link errors go away.

Patch:

Sean

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [September 13, 2018, 10:34pm UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290/2 "2018-09-13T22:34:24Z")

</div>

Thanks for sharing your issues and patch, Sean. The fix has been merged to `master`:

[http://review.source.kitware.com/#/c/23711/](http://review.source.kitware.com/#/c/23711/)

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [September 13, 2018, 10:37pm UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290/3 "2018-09-13T22:37:32Z")

</div>

What’s not clear to me is why this was needed.

Must we indeed do this on every platform and then union the results?

Sean

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [September 13, 2018, 10:44pm UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290/4 "2018-09-13T22:44:10Z")

</div>

> [@seanm](#):
>
> Must we indeed do this on every platform and then union the results?

Yes, that is a good idea.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 14, 2018, 2:52pm UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290/5 "2018-09-14T14:52:12Z")

</div>

> [@seanm](#):
>
> Must we indeed do this on every platform and then union the results?

Doing it on the three platforms might not be enough for ALL purposes. Depending on exact compiler versions, CMake configuration, other build settings and defines, the resulting list of symbols will probably vary. Doing all these combinations is not practical, given that there are thousands of symbols in HDF5 and they somewhat change between versions.

But generating the list for mangling on three platforms and taking the union is an excellent first step 😃 Then make additional fixes as needed.

As I use Mac the least, I probably didn’t add its specific symbols to the mangling list.

---

<div class="post-metadata">

### Author: ![gdevenyi](https://discourse.itk.org/user_avatar/discourse.itk.org/gdevenyi/32/355_2.png) [@gdevenyi](https://discourse.itk.org/u/gdevenyi)
#### Post date: [September 14, 2018, 5:10pm UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290/6 "2018-09-14T17:10:01Z")

</div>

@matt.mccormick given the call we had with the HDF5 group, maybe we should ask them to provide an comprehensive list somehow?

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [September 14, 2018, 6:00pm UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290/7 "2018-09-14T18:00:24Z")

</div>

Ideally, upstream would provide an HDF5 CMake variable that allows one to specify a symbol name mangling prefix.

---

<div class="post-metadata">

### Author: ![imikejackson](https://discourse.itk.org/user_avatar/discourse.itk.org/imikejackson/32/35_2.png) [@imikejackson](https://discourse.itk.org/u/imikejackson)
#### Post date: [September 17, 2018, 1:36am UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290/8 "2018-09-17T01:36:53Z")

</div>

I am really going to show my naivety on this: Why do we have to mangle the symbols? What does this guard against? I guess so that different libraries can compiled against different versions of HDF5?

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [September 17, 2018, 2:01am UTC](https://discourse.itk.org/t/vtk-master-itk-master-hdf5-duplicate-symbol-link-errors/1290/9 "2018-09-17T02:01:09Z")

</div>

Hi hi Mike!

If SomeApp™ already links against HDF5 (because it already uses it), then it wouldn’t be easy for that app to start using ITK because it’d get duplicate symbol link errors.

Sean
