# VTK\_USE\_FILE

**URL:** https://discourse.vtk.org/t/vtk-use-file/3645
**Category:** Development
**Created:** [June 25, 2020, 12:34pm UTC](https://discourse.vtk.org/t/vtk-use-file/3645 "2020-06-25T12:34:50Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![GeorgeS](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/bcef8e/32.png) [@GeorgeS](https://discourse.vtk.org/u/GeorgeS)
#### Post date: [June 25, 2020, 12:34pm UTC](https://discourse.vtk.org/t/vtk-use-file/3645/1 "2020-06-25T12:34:50Z")

</div>

I just upgraded from VTK-8.1.2 to VTK-9.0.0 and am getting a new segmentation fault:

[2A4FCA]vtkRayCastImageDisplayH:20  
WARN| Error: no override found for ‘vtkRayCastImageDisplayHelper’.  
Segmentation fault: 11

The offending line in my code is  
m\_smartVolumeMapperSurfaceRendered = vtkSmartPointer::New();

where the smart pointer has been declared in the corresponding .h file  
vtkSmartPointer m\_smartVolumeMapperSurfaceRendered;

I’m wondering if it is because, to get CMake to Configure and Generate, I had to remove the depreciated line in my CMake file

include(${VTK\_USE\_FILE})

but have not replaced it with anything.

Otherwise, it seems strange that I suddenly can’t declare a vtkSmartVolumeMapper object after upgrading VTK.

Any help would be appreciated.

---

<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 25, 2020, 1:09pm UTC](https://discourse.vtk.org/t/vtk-use-file/3645/2 "2020-06-25T13:09:02Z")

</div>

You’ll need to use the `autoinit` macros to do the work that `find_package` used to do behind the scenes.

```auto
target_link_libraries(mytarget ${any_vis} VTK::ModuleName1 VTK::ModuleName2)
# Add the following line.
vtk_module_autoinit(TARGETS mytarget MODULES VTK::ModuleName1 VTK::ModuleName2)

```

---

<div class="post-metadata">

### Author: ![GeorgeS](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/bcef8e/32.png) [@GeorgeS](https://discourse.vtk.org/u/GeorgeS)
#### Post date: [June 25, 2020, 2:07pm UTC](https://discourse.vtk.org/t/vtk-use-file/3645/5 "2020-06-25T14:07:03Z")

</div>

That worked!! Here are the two key lines in my CMake file for my project “bonezone”

target\_link\_libraries(bonezone ${Glue} ${VTK\_LIBRARIES} ${ITK\_LIBRARIES} ${OpenCV\_LIBS})  
vtk\_module\_autoinit(TARGETS bonezone MODULES ${VTK\_LIBRARIES} )

Many thanks.

---

<div class="post-metadata">

### Author: ![dr\_ppetrov](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dr_ppetrov/32/2121_2.png) [@dr\_ppetrov](https://discourse.vtk.org/u/dr_ppetrov)
#### Post date: [July 22, 2020, 5:59pm UTC](https://discourse.vtk.org/t/vtk-use-file/3645/6 "2020-07-22T17:59:25Z")

</div>

How about include dirs? ${VTK\_INCLUDE\_DIRS} is empty and the generated project has no reference to VTK dirs at all when I check in visual studio ☹ ???

---

<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: [July 23, 2020, 12:52am UTC](https://discourse.vtk.org/t/vtk-use-file/3645/7 "2020-07-23T00:52:16Z")

</div>

Use the targets. They get you everything you need.

---

<div class="post-metadata">

### Author: ![dr\_ppetrov](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dr_ppetrov/32/2121_2.png) [@dr\_ppetrov](https://discourse.vtk.org/u/dr_ppetrov)
#### Post date: [July 24, 2020, 10:18am UTC](https://discourse.vtk.org/t/vtk-use-file/3645/8 "2020-07-24T10:18:58Z")

</div>

Thanks, solved it! I also had to put it after linked\_targets call in cmake 😕 that solved it for me!

---

<div class="post-metadata">

### Author: ![nicoco](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/n/7c8e57/32.png) [@nicoco](https://discourse.vtk.org/u/nicoco)
#### Post date: [August 20, 2020, 2:49pm UTC](https://discourse.vtk.org/t/vtk-use-file/3645/9 "2020-08-20T14:49:28Z")

</div>

Before VTK 9, I was still able to compile [this rather old lib found in the VTK journal](https://www.vtkjournal.org/browse/publication/891).

My knowledge of C++ and CMake being more or less void, is there an easy fix to this CMakeList to make it VTK 9-compilable?

```
project( vtkMeshGeodesics )

find_package( VTK REQUIRED )
include( ${VTK_USE_FILE} )

set( vtkMeshGeodesics_SRCS
  vtkPolyDataGeodesicDistance.cxx
  vtkFastMarchingGeodesicDistance.cxx
  vtkFastMarchingGeodesicPath.cxx
  vtkPolygonalSurfaceContourLineInterpolator2.cxx )
set( vtkMeshGeodesics_HDRS
  vtkPolyDataGeodesicDistance.h
  vtkFastMarchingGeodesicDistance.h
  vtkFastMarchingGeodesicPath.h
  vtkPolygonalSurfaceContourLineInterpolator2.h )

include_directories( 
  ${CMAKE_CURRENT_SOURCE_DIR}/../FastMarching 
  ${CMAKE_CURRENT_SOURCE_DIR}/../FastMarching/gw_core
  ${CMAKE_CURRENT_SOURCE_DIR}/../FastMarching/gw_geodesic
)

add_library( vtkMeshGeodesics
  ${vtkMeshGeodesics_SRCS}
  ${vtkMeshGeodesics_HDRS} )
target_link_libraries( vtkMeshGeodesics MeshGeodesics )

```

Removing the `VTK_USE_FILE` line removes the CMake warning but compilation terminates with: `fatal error: vtkPolyDataAlgorithm.h: file not found`

I tried appending

```
vtk_module_autoinit(
  TARGETS vtkMeshGeodesics
  MODULES
    VTK::WrappingTools
    [...]
)

```

“[…]” being replaced by the list of all VTK modules I could find with a very subtle: `grep "Create imported target VTK::" VTK-9.0.1/build/lib/cmake/vtk-9.0/VTK-targets.cmake | cut -c25-` but it did not help.

So… is this easily fixable?

---

<div class="post-metadata">

### Author: ![Mathilde](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@Mathilde](https://discourse.vtk.org/u/Mathilde)
#### Post date: [August 21, 2020, 7:06am UTC](https://discourse.vtk.org/t/vtk-use-file/3645/10 "2020-08-21T07:06:06Z")

</div>

try using `include_directories(${VTK_INCLUDE_DIRS})` instead of  
`include( ${VTK_USE_FILE} )` 🙂

---

<div class="post-metadata">

### Author: ![nicoco](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/n/7c8e57/32.png) [@nicoco](https://discourse.vtk.org/u/nicoco)
#### Post date: [August 21, 2020, 7:23am UTC](https://discourse.vtk.org/t/vtk-use-file/3645/11 "2020-08-21T07:23:04Z")

</div>

I also had to add `target_link_libraries( vtkMeshGeodesics MeshGeodesics ${VTK_LIBRARIES} )` for all the includes to be found! Now it doesn’t compile, but for other reasons. Thanks @Mathilde!
