Compiler error when adding VTK static library files to Qt project file

Hi,

I am trying to add the VTK static library files to Qt Project, but I get linker error LNK2019. The same vtk library files when used with the visual studio they compile without any errors and program works well. I had checked that all the required library files are added. And also I am not sure if the order of the static VTK library files I had included is correct. Following is the list of order in which the library files are added to qt project. Could someone kindly suggest if the order of the list is valid.

Operating System Windows 10, Qt 5.14.1

I had tried checking the comments in the links below but didn’t solve the problem.

I had also checked the similar issue posted here on the forum .

Compiler Error Received:

vtkCommonCore-8.2.lib(vtkDebugLeaks.obj) : error LNK2019: unresolved external symbol __imp_MessageBoxA referenced in function "protected: static int __cdecl vtkDebugLeaks::DisplayMessageBox(char const *)" (?DisplayMessageBox@vtkDebugLeaks@@KAHPEBD@Z)
vtkCommonCore-8.2.lib(vtkWin32OutputWindow.obj) : error LNK2001: unresolved external symbol __imp_MessageBoxA
vtkCommonCore-8.2.lib(vtkWin32OutputWindow.obj) : error LNK2019: unresolved external symbol __imp_GetStockObject referenced in function "protected: static int __cdecl vtkWin32OutputWindow::Initialize(void)" (?Initialize@vtkWin32OutputWindow@@KAHXZ)
vtkRenderingOpenGL2-8.2.lib(vtkWin32OpenGLRenderWindow.obj) : error LNK2001: unresolved external symbol __imp_GetStockObject
vtkCommonCore-8.2.lib(vtkWin32OutputWindow.obj) : error LNK2019: unresolved external symbol __imp_SendMessageA referenced in function "protected: static void __cdecl vtkWin32OutputWindow::AddText(char const *)" (?AddText@vtkWin32OutputWindow@@KAXPEBD@Z)
vtkCommonCore-8.2.lib(vtkWin32OutputWindow.obj) : error LNK2019: unresolved external symbol __imp_DefWindowProcA referenced in function "__int64 __cdecl vtkWin32OutputWindowWndProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?vtkWin32OutputWindowWndProc@@YA_JPEAUHWND__@@I_K_J@Z)
vtkRenderingOpenGL2-8.2.lib(vtkWin32OpenGLRenderWindow.obj) : error LNK2001: unresolved external symbol __imp_DefWindowProcA
vtkCommonCore-8.2.lib(vtkWin32OutputWindow.obj) : error LNK2019: unresolved external symbol __imp_RegisterClassA referenced in function "protected: static int __cdecl vtkWin32OutputWindow::Initialize(void)" (?Initialize@vtkWin32OutputWindow@@KAHXZ)
vtkRenderingOpenGL2-8.2.lib(vtkWin32OpenGLRenderWindow.obj) : error LNK2001: unresolved external symbol __imp_RegisterClassA
vtkCommonCore-8.2.lib(vtkWin32OutputWindow.obj) : error LNK2019: unresolved external symbol __imp_GetClassInfoA referenced in function "protected: static int __cdecl vtkWin32OutputWindow::Initialize(void)" (?Initialize@vtkWin32OutputWindow@@KAHXZ)
vtkRenderingOpenGL2-8.2.lib(vtkWin32OpenGLRenderWindow.obj) : error LNK2001: unresolved external symbol __imp_GetClassInfoA
vtkCommonCore-8.2.lib(vtkWin32OutputWindow.obj) : error LNK2019: unresolved external symbol __imp_CreateWindowExA referenced in function "protected: static int __cdecl vtkWin32OutputWindow::Initialize(void)" (?Initialize@vtkWin32OutputWindow@@KAHXZ)
vtkRenderingOpenGL2-8.2.lib(vtkWin32OpenGLRenderWindow.obj) : error LNK2001: unresolved external symbol __imp_CreateWindowExA
vtkCommonCore-8.2.lib(vtkWin32OutputWindow.obj) : error LNK2019: unresolved external symbol __imp_ShowWindow referenced in function "protected: static int __cdecl vtkWin32OutputWindow::Initialize(void)" (?Initialize@vtkWin32OutputWindow@@KAHXZ)
vtkRenderingOpenGL2-8.2.lib(vtkWin32OpenGLRenderWindow.obj) : error LNK2001: unresolved external symbol __imp_ShowWindow
vtkCommonCore-8.2.lib(vtkWin32OutputWindow.obj) : error LNK2019: unresolved external symbol __imp_MoveWindow referenced in function "__int64 __cdecl vtkWin32OutputWindowWndProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?vtkWin32OutputWindowWndProc@@YA_JPEAUHWND__@@I_K_J@Z)

Order of the libraries used

LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lOPENGL32_
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtksys-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkCommonCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkCommonMath-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkCommonMisc-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkCommonSystem-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkCommonTransforms-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkCommonDataModel-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkCommonColor-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkCommonExecutionModel-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkCommonComputationalGeometry-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersGeneral-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingFourier-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersStatistics-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersExtraction-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkInfovisCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersGeometry-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersSources-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkzlib-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkfreetype-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingFreeType-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingContext2D-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkChartsCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkDICOMParser-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkdoubleconversion-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtklz4-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtklzma-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOLegacy-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkexpat-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOXMLParser-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkDomainsChemistry-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkglew-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingOpenGL2-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkDomainsChemistryOpenGL2-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOXML-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkParallelCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersAMR-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersFlowPaths-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersGeneric-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingSources-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersHybrid-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersHyperTree-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingGeneral-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersImaging-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersModeling-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersParallel-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersParallelImaging-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersPoints-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersProgrammable-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersSMP-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersSelection-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersTexture-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersTopology-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkverdict-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkFiltersVerdict-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkmetaio-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkjpeg-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkpng-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtktiff-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOImage-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingHybrid-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkInfovisLayout-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkInteractionStyle-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingColor-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingAnnotation-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingVolume-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkInteractionWidgets-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkViewsCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkproj-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkGeovisCore-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkhdf5-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkhdf5_hl-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOAMR-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOAsynchronous-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkpugixml-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOCityGML-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOEnSight-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkNetCDF-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkexodusII-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOExodus-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkgl2ps-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingGL2PSOpenGL2-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOExport-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOExportOpenGL2-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtklibharu-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOExportPDF-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOGeometry-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOImport-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtklibxml2-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOInfovis-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOLSDyna-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOMINC-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkogg-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtktheora-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOMovie-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIONetCDF-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOPLY-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkjsoncpp-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOParallel-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOParallelXML-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtksqlite-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOSQL-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOSegY-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOTecplotTable-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOVeraOut-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkIOVideo-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingMath-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingMorphological-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingStatistics-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkImagingStencil-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkInteractionImage-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingContextOpenGL2-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingImage-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingLOD-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingLabel-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkRenderingVolumeOpenGL2-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkViewsContext2D-8.2
LIBS += -L$$PWD/ExternalLibraries/VTK/lib/debug/ -lvtkViewsInfovis-8.2

I solved the issue. Adding windows related library files solved the issue i.e. user32.lib, opengl32.lib etc…

1 Like

I am having the exact same problem, but cant seem to solve.

I have a dynamic VTK build which works perfectly, but when I change my include path and libs path to the static build, I get a whole host of unresolved external symbol errors (183 of them!)

By manually adding in:
LIBS += “C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64\Gdi32.Lib”
LIBS += “C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64\OpenGL32.Lib”
LIBS += “C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64\windowscoreheadless.Lib”

I can get the errors down to just 3:
vtksys-9.0.lib(SystemInformation.obj):-1: error: LNK2019: unresolved external symbol __imp_SymGetLineFromAddr64
vtksys-9.0.lib(SystemInformation.obj):-1: error: LNK2019: unresolved external symbol __imp_SymInitialize
vtksys-9.0.lib(SystemInformation.obj):-1: error: LNK2019: unresolved external symbol __imp_SymFromAddr

Do you have the full list of the windows related library files that you had to add? I have no idea which I am missing.

For anybody else, I resolved the issue by including these windows lib files:
opengl32.lib user32.lib gdi32.lib advapi32.lib windowscoreheadless.lib nanosrv.lib

I did this by brute force - added all the libraries and removed them one by one until I found the ones needed.