I have built VTK-9.1.0 Static library by keeping BUILD_SHARED_LIBS = OFF.
But when I use this library in my module[vtkDlgApp] I get Linking errors.
Severity Code Description Project File Line Suppression State
Error LNK2038 mismatch detected for ‘RuntimeLibrary’: value ‘MDd_DynamicDebug’ doesn’t match value ‘MTd_StaticDebug’ in StdAfx.obj vtkDlgApp D:\DataDesignProjects\VTK_Examples\Build\vtkDLG\vtkRenderingOpenGL2-9.1d.lib(vtkRenderingOpenGL2ObjectFactory.obj) 1
vtkDlgApp: Project settings
Use of MFC = Use Standard Windows Libraries
Runtime Library = Multi-threaded Debug (/MTd)
If I change the porject settings to dynamic then vtkDlgApp exe is built.
Use of MFC =Use MFC in a Shared DLL
Runtime Library = Multi-threaded Debug DLL (/MDd)
I think, there is problem in VTK-9.1.0 Static library .
So can anybody help building the VTK-9.1.0 Static library and using it in a MFC dialog module?
It means that a static kit build makes no sense. So if you’re making a static build, the user’s kit request is just ignored and treated as if it is off.
As for the main question…it seems you’re trying to request a Debug build from CMake, but then try to use a release version of MFC. This is not supported. If this isn’t correct, more specific information will be needed.
I am also looking to statically link Qt to VTK at runtime. Can someone explain why a static build of VTK makes no sense in this case ? I built Qt 5.15.2 debug libs statically, configuring with -static and -static-runtime and ensuring /MTd was set in mkspecs for win32-msvc . I run CMake on my vtk 9.1 source, turned off SHARED_LIBS, build Debug. When I open the VS sln in VS 2020, the flags are all set to /MD and not /MTd .
cd c:
mkdir c:\code
cd c:\code
mkdir C:\code\repository
mkdir C:\code\build
cd C:\code\repository
git clone https://github.com/Kitware/VTK.git
run cmakegui
point to vtk source folder
point to vtk build folder
click Configure
uncheck build_shared_libs
cmake_configuration_types Debug
qt5_dir C:/Qt/qt5-static/lib/cmake/Qt5
check Advanced
vtk_group_enable_qt=WANT
VTK_MODULE_ENABLE_VTK_GUISupportQtQuick:STRING=DONT_WANT
add STRING var in CMakeGUI:
CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug
open solution in VS → Build → ALL_BUILD
after completion, in shell
cd c:\code\build\vtk_9.1.0
cmake -P cmake_install.cmake