# Prevent symbols from being only local to the library?

**URL:** https://discourse.vtk.org/t/prevent-symbols-from-being-only-local-to-the-library/8752
**Category:** Support
**Created:** [June 16, 2022, 8:34pm UTC](https://discourse.vtk.org/t/prevent-symbols-from-being-only-local-to-the-library/8752 "2022-06-16T20:34:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jrobcary](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@jrobcary](https://discourse.vtk.org/u/jrobcary)
#### Post date: [June 16, 2022, 8:34pm UTC](https://discourse.vtk.org/t/prevent-symbols-from-being-only-local-to-the-library/8752/1 "2022-06-16T20:34:37Z")

</div>

I have been trying to link a code to vtk using gcc-11.2.0.

The link fails with

/usr/bin/ld: /…/vtk4ctk-8.1.0-sersh/lib/libvtkCommonExecutionModel-8.1.so.1: undefined reference to `vtkCollectionIterator::GoToFirstItem()’  
…

but I see that in vtkCommonCore, which is present on the link line (see attached build log), is installed. However, nm shows

$ nm -CB libvtkCommonCore-8.1.so | grep GoToFirstItem  
00000000000e4b10 t vtkCollectionIterator::GoToFirstItem()  
00000000001b3f30 t vtkInformationIterator::GoToFirstItem()  
0000000000063ab0 t vtkInformationIterator::GoToFirstItem() [clone .cold]

that this symbol, while present, is local to the library. Hence, the link fails.

This is not a problem with gcc-8.3.0 on this machine or gcc-9.4.0 on a different machine.

This is a problem with gcc-10.3.0, gcc-11.2.0, which it seems I need to use to get the C++ features that I want.

Same problem occurs for vtk-8.2.0.

How do I make these symbols not local to the library?

Thx…John Cary

---

<div class="post-metadata">

### Author: ![jrobcary](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@jrobcary](https://discourse.vtk.org/u/jrobcary)
#### Post date: [June 16, 2022, 9:02pm UTC](https://discourse.vtk.org/t/prevent-symbols-from-being-only-local-to-the-library/8752/2 "2022-06-16T21:02:53Z")

</div>

I see now that “-fvisibility=hidden” is being added as a compilation flag. Any idea where this comes from?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [June 16, 2022, 10:20pm UTC](https://discourse.vtk.org/t/prevent-symbols-from-being-only-local-to-the-library/8752/3 "2022-06-16T22:20:33Z")

</div>

VTK sets it itself. However, this does work on GCC 11 in CI. Though I see that you’re talking about VTK 8.

VTK 8.1 is really out-of-date and unsupported. I suspect this is something that got fixed in the new module system.

---

<div class="post-metadata">

### Author: ![jrobcary](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@jrobcary](https://discourse.vtk.org/u/jrobcary)
#### Post date: [June 17, 2022, 2:28am UTC](https://discourse.vtk.org/t/prevent-symbols-from-being-only-local-to-the-library/8752/4 "2022-06-17T02:28:42Z")

</div>

8.2.0 has the same problem. I fix this by, after configuring, running

find . -name flags.make -exec sed -i -e ‘s/-fvisibility=hidden//g’ ‘{}’ ;

Where in vtk does -fvisibility=hidden get added? (Then I can just patch it.)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [June 21, 2022, 10:05pm UTC](https://discourse.vtk.org/t/prevent-symbols-from-being-only-local-to-the-library/8752/5 "2022-06-21T22:05:15Z")

</div>

There’s a variable `CMAKE_CXX_VISIBILITY_PRESET` that gets set somewhere in 8.2 (probably top-level `CMakeLists.txt`. The `CMAKE_C_VISIBILITY_PRESET` variable also needs cleared. You can set it to `default` instead of `hidden`.
