# Cmake: impossible to open .h files

**URL:** https://discourse.vtk.org/t/cmake-impossible-to-open-h-files/10995
**Category:** Support
**Created:** [March 17, 2023, 1:07am UTC](https://discourse.vtk.org/t/cmake-impossible-to-open-h-files/10995 "2023-03-17T01:07:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![antoine1](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/73ab20/32.png) [@antoine1](https://discourse.vtk.org/u/antoine1)
#### Post date: [March 17, 2023, 1:07am UTC](https://discourse.vtk.org/t/cmake-impossible-to-open-h-files/10995/1 "2023-03-17T01:07:28Z")

</div>

Hello,

I tried to include vtk to code and to use it but it’s look like cmake was not able to find .h files.

i include VTK using this cmake code:

```auto
set(VTK_DIR "C:/vtk/VTK-9.2.6-install/lib/cmake/vtk-9.2/")
function(add_vtk libname)
    find_package(VTK REQUIRED)
    target_link_libraries( ${libname} PRIVATE ${VTK_LIBRARIES})
endfunction()

```

then in sub directory where i need vtk i just call the function and i put the name of the library.

I checked if VTK\_LIBRARIES is not empty and it’s not.

Also, i was able to code a method using vtk without any error. visual studio have access to definitions of vtk objects as it’s showing me members of vtk objects but for an obscure reason when i push the button to launch it, after the cmake generation (which is going well), the code bug.

also, when i wrote:

```auto
vtkSmartPointer<vtkPlot> line = vtkSmartPointer<vtkPlot>::New()

```

the code return me an error like:

‘’ : impossible to convert from ‘initializer list’ into 'vtkSmartPointer

which redirect me to the vtkSmartPointer.h file…

I really dont get this magic.

someone have an idea before i burn my wizard computer?

thank you in advance !

---

<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: [March 19, 2023, 12:22am UTC](https://discourse.vtk.org/t/cmake-impossible-to-open-h-files/10995/2 "2023-03-19T00:22:04Z")

</div>

Can you please provide the full source that you tried? This sounds like a missing `#include`, but it’s hard to say.

---

<div class="post-metadata">

### Author: ![antoine1](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/73ab20/32.png) [@antoine1](https://discourse.vtk.org/u/antoine1)
#### Post date: [March 19, 2023, 12:26am UTC](https://discourse.vtk.org/t/cmake-impossible-to-open-h-files/10995/3 "2023-03-19T00:26:47Z")

</div>

thank you.

I already solved it.

Include was not the problem. the problem was:

i had to add the add\_vtk() in all cmakelists from the root to the subdirectory which contain the code.
