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

**URL:** https://discourse.vtk.org/t/compiler-error-when-adding-vtk-static-library-files-to-qt-project-file/2597
**Category:** Support
**Created:** [February 12, 2020, 8:39pm UTC](https://discourse.vtk.org/t/compiler-error-when-adding-vtk-static-library-files-to-qt-project-file/2597 "2020-02-12T20:39:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jay](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Jay](https://discourse.vtk.org/u/Jay)
#### Post date: [February 12, 2020, 8:39pm UTC](https://discourse.vtk.org/t/compiler-error-when-adding-vtk-static-library-files-to-qt-project-file/2597/1 "2020-02-12T20:39:14Z")

</div>

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.

> **[Problem linking a foreign static library](https://forum.qt.io/topic/950/problem-linking-a-foreign-static-library/4)**
>
> Hi, I'm working with Qt-4.6.3 and VTK on Windows (MinGW), Linux and Mac-OSX. My app is working on these platforms, but I am exploring static link possibilities to simplify deployment. I'm starting with the Windows-MinGW platform, and have built the...

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

> [@Compile error when use VTK static library in QT Creator](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039):
>
> Hi, I’m trying to use VTK static lib in QT Creator, but got so many compile error(\> 2000), if I compile the same program with VTK dynamic lib, no error and the program works well. I have already add all VTK libraries in the pro file, and also changed vtkConfigure.h follow the instruction in [https://forum.qt.io/topic/950/problem-linking-a-foreign-static-library/4](https://forum.qt.io/topic/950/problem-linking-a-foreign-static-library/4) but can’t fix the problem yet. Below are some error I got: /home/edward/workings/vtk/vtk-static/lib/libvtkCommonColor-8.2.a(vtkNa…

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

---

<div class="post-metadata">

### Author: ![Jay](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Jay](https://discourse.vtk.org/u/Jay)
#### Post date: [February 13, 2020, 3:58pm UTC](https://discourse.vtk.org/t/compiler-error-when-adding-vtk-static-library-files-to-qt-project-file/2597/2 "2020-02-13T15:58:12Z")

</div>

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

---

<div class="post-metadata">

### Author: ![AhmedAlshawi](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@AhmedAlshawi](https://discourse.vtk.org/u/AhmedAlshawi)
#### Post date: [December 8, 2021, 11:57pm UTC](https://discourse.vtk.org/t/compiler-error-when-adding-vtk-static-library-files-to-qt-project-file/2597/3 "2021-12-08T23:57:52Z")

</div>

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)👎 error: LNK2019: unresolved external symbol \_\_imp\_SymGetLineFromAddr64  
vtksys-9.0.lib(SystemInformation.obj)👎 error: LNK2019: unresolved external symbol \_\_imp\_SymInitialize  
vtksys-9.0.lib(SystemInformation.obj)👎 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.

---

<div class="post-metadata">

### Author: ![AhmedAlshawi](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@AhmedAlshawi](https://discourse.vtk.org/u/AhmedAlshawi)
#### Post date: [December 9, 2021, 10:18pm UTC](https://discourse.vtk.org/t/compiler-error-when-adding-vtk-static-library-files-to-qt-project-file/2597/4 "2021-12-09T22:18:54Z")

</div>

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.
