VTK 9.2.6 missing dll

Hello everyone,

I’m new in vtk and i try to add it to my cmake for a new project with QT.
I had vtk to my cmake like this:


set(VTK_DIR "C:/vtk/VTK-9.2.6-install/lib/cmake/vtk-9.2/") 
find_package(VTK REQUIRED)
target_link_libraries( AstroBase PRIVATE ${VTK_LIBRARIES})

When i try to launch a test, a message box open to inform me that some .dll are missing.

I have set ass system variables path %VTK_DIR%/bin. (I work on windows with visual studio community) but it look like cmake do not go to search into this path variable.

I tried to message($env{PATH}) to see what path contains and i found that the path variable return from cmake is totally difference from the one that i setup in my environnement variables from windows. It’s look like more link to visual studio than windows. (Yes I’m also beginner with cmake.)

As i don’t want to copy all the bin directory to my project i would like to setup properly my cmake to go to search into the good directory.

do you know how can i solve it?

thank you in advance!

The VTK_DIR value you have set points to the files cmake needs inside the VTK install, but not the DLLs. Looks like they will be in “C:/vtk/VTK-9.2.6-install/bin” - try adding that to your path.

Also, how are you launching a test? That may affect how env-vars like PATH are set.
HTH,
Aron

Thank you for your reply.

Yes sorry i didn’t mention but in my cmake VTK_DIR point to cmake config files but in my windows environnement variable VTK_DIR point to C:/vtk/VTK-9.2.6-install/.

So in path when i set up %VTK_DIR%/bin the valeur should be C:/vtk/VTK-9.2.6-install/bin.

I launch my test via visual studio. I just select the executable file main and launch it.

How can i specify to cmake to check the system environnement variables and not the one from visual studio?

I don’t think cmake is involved - it’s just building your app, and that’s been done already.
If you launch the test inside VS, then VS is controlling the environment. I think you want to look at the Debug menu, and the config Debug Properties item at the bottom - the VC++ Directories … Executable Directories entry gives you control of the PATH.

Ok so i tried what you said but i didn’t had the VC++ directories.
But i finally found the solution.

With visual studio and cmake, the environnement is manage by the file CMakeSettings.json.

In this file, i just add at the top of the json as global declaration (before configuration):


  "environments": [
    {
      "PATH": "${env.PATH};C:\\vtk\\VTK-9.2.6-install\\bin"
    }
  ]

and that work.

Thank you for your help