# Problem loading dynamic library linked to ITK from a program also linked to ITK

**URL:** <https://discourse.itk.org/t/problem-loading-dynamic-library-linked-to-itk-from-a-program-also-linked-to-itk/1319>\
**Category:** Engineering\
**Created:** [September 28, 2018, 8:46pm UTC](https://discourse.itk.org/t/problem-loading-dynamic-library-linked-to-itk-from-a-program-also-linked-to-itk/1319 "2018-09-28T20:46:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baptiste](https://discourse.itk.org/letter_avatar_proxy/v4/letter/b/cab0a1/32.png) [@Baptiste](https://discourse.itk.org/u/Baptiste)\
**Post date:** [September 28, 2018, 8:46pm UTC](https://discourse.itk.org/t/problem-loading-dynamic-library-linked-to-itk-from-a-program-also-linked-to-itk/1319/1 "2018-09-28T20:46:00Z")

</div>

Hello all,

I am trying to load at runtime a dynamic library using ITK (let’s call it  
lib.so), within a program also linked to ITK.  
To do this, I am using :

`void* handle = dlopen("lib.so", RTLD_LOCAL | RTLD_LAZY)`

but it crashes (I receive an `H5::DataSpaceIException`).

This works when I remove linking to ITK from the program that use the  
library, or when I remove it from the library itself, so I guess I have  
conflicting links between both programs, but I can’t figure it out.

Thank you !

---

<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:** [October 1, 2018, 2:59pm UTC](https://discourse.itk.org/t/problem-loading-dynamic-library-linked-to-itk-from-a-program-also-linked-to-itk/1319/2 "2018-10-01T14:59:40Z")

</div>

Hello @Baptiste!

Were you using ITK Git `master`? The latest ITK Git `master` and ITK 4.13.1 both have fixes for the HDF5 library symbol name mangling, which could possibly be related. They are worth a try. Or, set `ITK_USE_SYSTEM_HDF5` and point the build system to a system HDF5.

HTH,  
Matt

---

<div class="post-metadata">

**Author:** ![Baptiste](https://discourse.itk.org/letter_avatar_proxy/v4/letter/b/cab0a1/32.png) [@Baptiste](https://discourse.itk.org/u/Baptiste)\
**Post date:** [October 8, 2018, 9:02am UTC](https://discourse.itk.org/t/problem-loading-dynamic-library-linked-to-itk-from-a-program-also-linked-to-itk/1319/3 "2018-10-08T09:02:32Z")

</div>

Hello @matt.mccormick,

I was already using ITK 4.13.1, but I tried with ITK\_USE\_SYSTEM\_HDF5 option and it works, I can now load the library.

Thanks a lot for your answer !  
Baptiste
