问题
I'm trying to link VTK library to my project on Windows 7. The error I get is:
Error C1083 Cannot open include file: 'vtkGUISupportQtOpenGLModule.h': No such file or directory
The thing in my code that provokes the error is #include<QVTKWidget2.h>
.
Src and build directories of my VTK copy are separate. The linking tool I use is cmake
. The build tool: VS 2015
.
My CMakeLists.txt
and VTK's cache u can see below.
Thanks in advance for any suggestions.
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
set(PROJECT Pro)
project(${PROJECT})
set(BUILD_SHARED_LIBS false)
message(" BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
list(APPEND CMAKE_EXE_LINKER_FLAGS -static)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
set(VTK_INCLUDE_DIRS
"D:/libs/VTK-7.1.1"
)
set(VTK_QT_INCLUDE_DIR
"D:/libs/VTK-7.1.1/GUISupport/QtOpenGL"
)
include_directories(${VTK_INCLUDE_DIRS} ${VTK_QT_INCLUDE_DIR})
# ... Local src declaration
add_executable(${PROJECT} ${PRO_APP_HEADERS}${PRO_APP_SOURCES})
if(VTK_LIBRARIES)
message("VTK_LIBRARIES is set.")
target_link_libraries(${PROJECT} ${VTK_LIBRARIES})
else(VTK_LIBRARIES)
message("! VTK_LIBRARIES are not set completely")
target_link_libraries(${PROJECT} vtkHybrid vtkWidgets)
endif(VTK_LIBRARIES)
VTK's cache enter image description here
回答1:
Click on "Advanced" in the VTK's CMake (on the top, next to the search bar), you will see many more options. One of them is Module_vtkGUISupportQtOpenGL, make sure it is checked.
In your CMake, I don't think your include_directories clause does anything. The paths you are linking to are not to the library, but rather to the sources of the library, the actual path to the library would be D:\VTK_build_directory\include\vtk-7.1.1\
, where VTK_build_directory is wherever you build VTK (I recommend using INSTALL
to build VTK, then the result will be in the CMAKE_INSTALL_PREFIX directory, which you can specify in VTK's CMake). However, in any case it is not needed anyway since you are already using the include(${VTK_USE_FILE})
, which will setup all include files. So, unless there is some other use not apparent from your example, you can delete the whole
set(VTK_INCLUDE_DIRS
"D:/libs/VTK-7.1.1"
)
set(VTK_QT_INCLUDE_DIR
"D:/libs/VTK-7.1.1/GUISupport/QtOpenGL"
)
include_directories(${VTK_INCLUDE_DIRS} ${VTK_QT_INCLUDE_DIR})
回答2:
Ensure that file "vtkGUISupportQtOpenGLModule.h" is actually located in one of those included dirs (${VTK_INCLUDE_DIRS} or ${VTK_QT_INCLUDE_DIR}) (you did not mention whether it is there), and that you have permissions to it.
来源:https://stackoverflow.com/questions/47285921/errorc1083cannot-open-include-file-vtkguisupportqtopenglmodule-h-no-such-f