Issue Running Animations in VR

What I said earlier about it not being able to open “openvr.h” doesn’t seem to be the case anymore. I don’t know what happened, I don’t think I did anything, but it gives a new error now when I try to build the solution file. This is what it’s giving me:

I tried searching up the error online, and got the following: Correct linking vs. building from src · Issue #364 · ValveSoftware/openvr · GitHub. Here, the commenter says this error can come up when you forget to include openvr_api.lib, but I did that when configuring and generating with CMake. However, they also mention a workaround, where I can add the location as an additional dependency in Linker-> Input under Configuration Properties. But when I went to configuration properties of All Build, I could not see any option for Linker. I have attached what I see on my end below:
image
Is there something I’m missing, or another way to get this error to go away and move forward with the build process?

Adding on to my last post, I was able to get the Linker option to come up. I poked around a bit online and found I could do it by changing the configuration type to dynamic library. Then, I was able to add the directory to openvr_api.lib in linker. However, the same error as before came after trying to build again, so I’m guessing that wasn’t the solution. Please advise on what to do.

With CMake you should not be editing the settings in Visual Studio IDE. That isn’t how CMake works. CMake generates the solution files which the IDE uses (or having to copy files, headers etc). If there are issues you need to rerun/change settings in CMake, not the IDE. I use ninja on windows in a VS shell and it works fine. To build I clone vtk, clone openvr, run cmake-gui turn on RenderingOpenVR, point to the lib and header for OpenVR as you have done, select RelWithDebInfo as a config, configure, generate, then ninja to complete the build. Once VTK is built correctly, then you can run cmake on your app, point to where you built VTK, and then ninja your app. The same idea should work when using the VS IDE, but if this is your first time using CMake + building on VS + VTK then that is a whole lot to take on all at once. You might want to start clean and at least see if you can get a clean VTK build first (with OpenVR turned on). Then after that work on the build for your app.

Thank you. Yes, I am trying to get my VTK build working before trying to get my app working. I have tried starting clean with a new build, turning on RenderingOpenVR, TestingCore, and TestingRendering, and pointing cmake to the lib and header. I also set CMake_Configuration_Types as you specified to just RelWithDebInfo. Then, I configured and generated from the VTK folder to VTKbuild. However, when I tried to build the resulting solution file using VS, I got the same error as before, as shown below

Based on what you said, I guess this means something was wrong in CMake, not Visual Studio. Is there a setting that I messed up or need to change?

So regarding the error in my previous post, when I searched it up I got the following: Correct linking vs. building from src · Issue #364 · ValveSoftware/openvr · GitHub. Like I said before, the commenter recommended adding the location as an additional dependency in Visual Studio because the error could occur if you forget to include openvr_api.lib. However, as you said the error wouldn’t be in Visual Studio, but in CMake, so does that mean I incorrectly linked the OpenVR library? The other threads I looked at online where people had similar problems all theorized the issue lied in the include libraries, which is why I’m guessing I might have incorrectly linked OpenVR in CMake.


I’ve re-attached the image just in case that would help determine if I incorrectly linked it. If what I did was wrong, how can I link it properly? If I did link it right, what else could be the cause of the error when I build the solution file?

I’m trying to think of other potential reasons things could have gone wrong. You didn’t mention turning on TestingCore and TestingRendering. Should I not have done that? I turned them on because that’s how I made my initial VTK build based on tutorials online. Are they no longer needed for the OpenVR VTK build, which is why I’m getting an error?

OK let’s start at the beginning. If you run into errors at any point stop and resolve those errors before moving forward.

  1. Wipe your binary trees, we don’t want them confusing things. If you messed with the source trees then do a git clean -f or similar to get back to a fresh clone. Git status should show no locally modified files or untracked files.

  2. download ninja from here https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip

  3. copy the ninja executable into somewhere in your path

3.5) Open a visual studio command shell. Go to start menu and scroll down to visual studio and select “x64 Native Tools Command Prompt” run the remaining commands from that shell

  1. create a new directory named release next to your vtk source tree named release

  2. cd into release

  3. run cmake-gui …\vtk

6.1) hit configure

6.2) when prompted pick ninja as the generator and “use default native compilers” If you get errors etc then you either do not have ninja in your path or you are not in the right visual studio shell. Stop and fix that first.

6.5) change the CMAKE_BUILD_TYPE to RelWithDebInfo

  1. press the configure button

  2. turn on the vtkRenderingOpenVR module, configure again

  3. provide the openvr paths for th eheaders and library as you did above in this thread, those values look fine.

  4. hit configure again, it should now be without errors

  5. hit generate

  6. close cmake-gui

  7. run ninja from your shell

  8. it should build VTK with openVR support

Thank you for the detailed steps. For step 1, I don’t think I git cloned anything, I simply downloaded all necessary folders by hand. Because of that, I don’t think git clean -f or git status will work. Instead, should I simply delete the vtkbuild folder?

Yes delete the build folder.

I think I followed all of the steps you specified correctly, but when it came time for step 13 to run ninja, I got the same error as before, as shown below.

You need VTK master. VTK 8.2 is way too old. Wipe your bin and source trees and start again with VTK master.

Thank you. I’ve gotten rid of VTK 8.2 and repeated the steps with VTK master. I was able to run the build without issues now. However, I no longer see a VTK folder in Project Files (x86), and because of that my previous application cannot run. Is there a way to create that folder?

Great so VTK is now built with OpenVR support. So the next step is to build your application against the VTK you just built. Normally you would

  1. create a release directory next to your application source tree

1.5) lauch a visual studio native shell like described previously

  1. cd into release

  2. run cmake-gui …\yourapp

  3. Do the same first couple steps with cmake-gui as you did for VTK (select ninja, configure, set build type to RelWithDebInfo)

  4. point VTK_DIR cmake variable to where you built VTK

  5. do a final configure and generate

  6. run ninja

At that point if ninja ran successfully you should have a compiled executable. If you ran into issues it could be in your cmakeLists file for your app.

To run your application you will get errors about missing DLLs at first. When you get to this point let me know and I can point you in the right direction. You can either copy all the required dlls into a common directory with your executable or you can setup paths etc. You will also need to copy the json files from VTK for VR controller bindings if you copy the dlls. The openvr dll can be found in the checkout you did of openvr.

Hi, I was able to perform your steps and create the executable, but as you said I’m getting the missing DLL error.

Great, create a install directory somewhere.

  1. copy your executable there

  2. Copy everything from your vtk build’s bin directory there (aka release\bin*)

  3. copy the openvr_api.dll from yoru openvr checkout to the install directory

  4. run your executable, if you get missing dll errors hunt them down and copy them to the install directory

I was able to get the dll errors to go away using your steps, and my original application is now able to run.

Now, I tried to change the application to work with openVR, and tried performing the same steps you outlined again on this one. However, when I tried to configure it, I got the following message:

Please post your cmakeLists file for your project

CMakeLists.txt (1.2 KB)

The error is because of line 21. I added it because I was trying to fix what would happen without it, where I would get an error like the following:

On line 21 you have vtkOpenVRRenderWindow when it should be vtkRenderingOpenVR

Great, thanks. The error has gone away, and I was able to configure, generate, and build my revised application. In this application, I have replaced Camera, Renderer, RenderWindow and RenderWIndowInteractor with the OpenVR versions. Then, I put the exe in the folder with all the dll’s like before, and also added the openvr dll. Then, when I ran the exe, I got a message saying the exe had stopped working.

Is this because I’m running it on the computer instead of my VR headset? If I need to use the headset, would I just need to start SteamVR and then start the exe?