Hello,everyone can you help me?
I encountered the following problem when I copied and ran the FourPaneViewer code in Qtcreator today. There are so many __imp__xxxx flags and too many errors make me nervous and doubtful: What should I do?
Error:
Environment:
Windows10, QtCreator with Qt6.8.0, vtk9.3.1(which build debug mode)
Changed:
I just separated the vtkResliceCursorCallback class inherited from the vtkCommand class and wrote it into vtkResliceCursorCallback.h and vtkResliceCursorCallback.cpp.this is my demo tree.
CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(QtVtkRenderWindowsUpdate VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(VTK_DIR "./vtk_build_ninja_D/lib/cmake/vtk-9.3")
find_package(VTK
COMPONENTS
CommonCore
GUISupportQt
IOImage
ImagingColor
ImagingGeneral
InteractionImage
InteractionStyle
InteractionWidgets)
if (NOT VTK_FOUND)
message("Skipping example: ${VTK_NOT_FOUND_MESSAGE}")
return ()
endif ()
set(QT6_DIR "E:/qqt/6.8.0/msvc2022_64/lib/cmake/Qt6")
set(Qt6Quick_DIR "E:/qqt/6.8.0/msvc2022_64/lib/cmake/Qt6Quick")
set(Qt6QuickTools_DIR "E:/qqt/6.8.0/msvc2022_64/lib/cmake/Qt6QuickTools")
set(Qt6Gui_DIR "E:/qqt/6.8.0/msvc2022_64/lib/cmake/Qt6Gui")
set(Qt6GuiTools_DIR "E:/qqt/6.8.0/msvc2022_64/lib/cmake/Qt6GuiTools")
set(Qt6Widgets_DIR "E:/qqt/6.8.0/msvc2022_64/lib/cmake/Qt6Widgets")
set(Qt6WidgetsTools_DIR "E:/qqt/6.8.0/msvc2022_64/lib/cmake/Qt6WidgetsTools")
set(Qt6OpenGL_DIR "E:/qqt/6.8.0/msvc2022_64/lib/cmake/Qt6OpenGL")
set(Qt6OpenGLWidgets_DIR "E:/qqt/6.8.0/msvc2022_64/lib/cmake/Qt6OpenGLWidgets")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core)
set(PROJECT_SOURCES
main.cpp
vtkResliceCursorCallback.h
vtkResliceCursorCallback.cpp
qtvtkrenderwindows.cpp
qtvtkrenderwindows.h
qtvtkrenderwindows.ui
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(QtVtkRenderWindowsUpdate
MANUAL_FINALIZATION
${PROJECT_SOURCES}
Icons/icons.qrc
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET QtVtkRenderWindowsUpdate APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(QtVtkRenderWindowsUpdate SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(QtVtkRenderWindowsUpdate
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(QtVtkRenderWindowsUpdate PRIVATE ${VTK_LIBRARIES} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Core)
target_include_directories(QtVtkRenderWindowsUpdate PRIVATE ${VTK_INCLUDE_DIRS})
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.QtVtkRenderWindowsUpdate)
endif()
set_target_properties(QtVtkRenderWindowsUpdate PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
include(GNUInstallDirs)
install(TARGETS QtVtkRenderWindowsUpdate
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(QtVtkRenderWindowsUpdate)
endif()
vtk_module_autoinit(TARGETS QtVtkRenderWindowsUpdate MODULES ${VTK_LIBRARIES})
I hope to get some help from all the masters passing by. I would like to thank you in advance.