# VTK error : linking shared libraries?

**URL:** https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393
**Category:** Support
**Created:** [October 11, 2020, 12:07pm UTC](https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393 "2020-10-11T12:07:28Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![astropiu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/astropiu/32/2443_2.png) [@astropiu](https://discourse.vtk.org/u/astropiu)
#### Post date: [October 11, 2020, 12:07pm UTC](https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393/1 "2020-10-11T12:07:29Z")

</div>

I just built and installed VTK version 9.0.1 for my ubuntu . I downloaded the cylinder example from the official site and was able to build it fine after fixing the RenderingContextOpenGL2 variable. But when i run the executable file , it displays this error:  
./CylinderExample: error while loading shared libraries: libvtkFiltersExtraction-9.0.so.1: cannot open shared object file: No such file or directory  
even though VTK is successfully installed and I was able to locate that shared object file in usr/local/lib

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 11, 2020, 2:26pm UTC](https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393/2 "2020-10-11T14:26:03Z")

</div>

Did you run `ldconfig` after installation?

When you install `.deb` packages, `ldconfig` runs automatically. But when you install manually with `make install`, you usually have to run `ldconfig` yourself.

If running `ldconfig` doesn’t help, then check `/etc/ld.so.conf.d/libc.conf` (or `/etc/ld.so.conf`) to make sure that `/usr/local/lib` is in your library path.

---

<div class="post-metadata">

### Author: ![astropiu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/astropiu/32/2443_2.png) [@astropiu](https://discourse.vtk.org/u/astropiu)
#### Post date: [October 12, 2020, 4:36am UTC](https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393/3 "2020-10-12T04:36:12Z")

</div>

It worked! I ran the ldconfig command from the build directory and now the example works. I’m new to Linux and this is my second make installation after opencv but had used opencv directly in my programs and not makefiles. Thanks for the help!  
I needed vtk because I read that cv::viz is built on it and couldn’t find the header in my include files. Do I need to rebuild and install opencv with vtk enabled for this ? Or is there any simpler fix?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 12, 2020, 4:49am UTC](https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393/4 "2020-10-12T04:49:29Z")

</div>

If you installed opencv via apt, apt-get, or the synaptics package manager then you should be able to do the same with cv::viz, and then the VTK package will be brought in automatically as a dependency.

```
apt-get install libopencv-viz-dev

```

But if you installed opencv from source code, then yes, you will have to re-configure opencv to build against VTK, and then rebuild and re-install opencv.

---

<div class="post-metadata">

### Author: ![astropiu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/astropiu/32/2443_2.png) [@astropiu](https://discourse.vtk.org/u/astropiu)
#### Post date: [October 12, 2020, 10:06am UTC](https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393/5 "2020-10-12T10:06:54Z")

</div>

Thanks again for the response! I installed it from source code and was trying to rebuild it. i get this error now:

CMake Error at /usr/local/lib/cmake/vtk-9.0/vtkModule.cmake:2955 (get\_property):  
get\_property could not find TARGET opencv\_viz. Perhaps it has not yet been  
created.  
Call Stack (most recent call first):  
/home/astropiu/Downloads/opencv\_contrib-master/modules/viz/CMakeLists.txt:43 (vtk\_module\_autoinit)  
modules/world/CMakeLists.txt:13 (include)  
modules/world/CMakeLists.txt:32 (include\_one\_module)

CMake Error at /usr/local/lib/cmake/vtk-9.0/vtkModule.cmake:2962 (target\_compile\_definitions):  
Cannot specify compile definitions for target “opencv\_viz” which is not  
built by this project.  
Call Stack (most recent call first):  
/home/astropiu/Downloads/opencv\_contrib-master/modules/viz/CMakeLists.txt:43 (vtk\_module\_autoinit)  
modules/world/CMakeLists.txt:13 (include)  
modules/world/CMakeLists.txt:32 (include\_one\_module)

This same error was posted by someone at opencv forum but is still unanswered. Should i try using previous version of vtk or opencv?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 12, 2020, 12:06pm UTC](https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393/6 "2020-10-12T12:06:42Z")

</div>

I don’t know which versions of opencv work with which versions of VTK. @opoplawski, do you have any experience with this?

---

<div class="post-metadata">

### Author: ![opoplawski](https://discourse.vtk.org/user_avatar/discourse.vtk.org/opoplawski/32/321_2.png) [@opoplawski](https://discourse.vtk.org/u/opoplawski)
#### Post date: [October 12, 2020, 1:45pm UTC](https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393/7 "2020-10-12T13:45:29Z")

</div>

I was able to build opencv 4.3.0 against vtk 9 with the addition of these upstream patches:

Patch1: [https://patch-diff.githubusercontent.com/raw/opencv/opencv/pull/17431.patch](https://patch-diff.githubusercontent.com/raw/opencv/opencv/pull/17431.patch)  
Patch2: [https://patch-diff.githubusercontent.com/raw/opencv/opencv\_contrib/pull/2549.patch](https://patch-diff.githubusercontent.com/raw/opencv/opencv_contrib/pull/2549.patch)

Looks like they made it into the 4.4.0 release.

---

<div class="post-metadata">

### Author: ![astropiu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/astropiu/32/2443_2.png) [@astropiu](https://discourse.vtk.org/u/astropiu)
#### Post date: [October 13, 2020, 10:51am UTC](https://discourse.vtk.org/t/vtk-error-linking-shared-libraries/4393/8 "2020-10-13T10:51:25Z")

</div>

I was able to build opencv 4.4.0 with vtk 8.2 without any issues through the same procedure that I tried with 9.0.1. I guess the latest releases aren’t compatible.
