# Compile error when use VTK static library in QT Creator

**URL:** https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039
**Category:** Development
**Created:** [May 29, 2019, 7:19am UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039 "2019-05-29T07:19:05Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Edward](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Edward](https://discourse.vtk.org/u/Edward)
#### Post date: [May 29, 2019, 7:19am UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039/1 "2019-05-29T07:19:05Z")

</div>

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(vtkNamedColors.cxx.o): In function `vtkNamedColors::GetColorNames(vtkStringArray*)': /home/edward/workings/vtk/VTK-8.2.0/Common/Color/vtkNamedColors.cxx:1027: undefined reference to`vtkStringArray::InsertNextValue(vtkStdString)’  
/home/edward/workings/vtk/vtk-static/lib/libvtkCommonExecutionModel-8.2.a(vtkAlgorithm.cxx.o): In function `vtkAlgorithm::vtkAlgorithm()': /home/edward/workings/vtk/VTK-8.2.0/Common/ExecutionModel/vtkAlgorithm.cxx:94: undefined reference to`vtkInformationVector::New()’  
/home/edward/workings/vtk/VTK-8.2.0/Common/ExecutionModel/vtkAlgorithm.cxx:95: undefined reference to `vtkInformationVector::New()' /home/edward/workings/vtk/VTK-8.2.0/Common/ExecutionModel/vtkAlgorithm.cxx:97: undefined reference to`vtkInformation::New()’  
/home/edward/workings/vtk/vtk-static/lib/libvtkCommonExecutionModel-8.2.a(vtkAlgorithm.cxx.o): In function `vtkAlgorithm::GetInputArrayFieldInformation(int, vtkInformationVector\*\*)’:

Thanks in advance.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 29, 2019, 12:14pm UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039/2 "2019-05-29T12:14:41Z")

</div>

It looks like you’re not linking to `vtkCommonCore`.

---

<div class="post-metadata">

### Author: ![Edward](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Edward](https://discourse.vtk.org/u/Edward)
#### Post date: [May 30, 2019, 8:58am UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039/3 "2019-05-30T08:58:26Z")

</div>

Thanks, I have already linked all VTK library files.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 30, 2019, 12:43pm UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039/4 "2019-05-30T12:43:10Z")

</div>

The linker thinks you’re not. The order of the libraries also matters for static linking on Linux. Could you paste the full link line that is being used?

---

<div class="post-metadata">

### Author: ![Edward](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Edward](https://discourse.vtk.org/u/Edward)
#### Post date: [May 30, 2019, 1:34pm UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039/5 "2019-05-30T13:34:37Z")

</div>

Yes, you are right.  
It seems like the libraries should be linked in some order, I don’t solve the problem yet, but the error reduce to 30+ now

Thanks！

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 30, 2019, 1:36pm UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039/6 "2019-05-30T13:36:31Z")

</div>

You’ll generally want `libhighlevel.a liblowlevel.a` ordering (so `vtkRenderingOpenGL2` before `vtkRenderingCore`).

---

<div class="post-metadata">

### Author: ![Edward](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Edward](https://discourse.vtk.org/u/Edward)
#### Post date: [May 30, 2019, 2:33pm UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039/7 "2019-05-30T14:33:58Z")

</div>

Thanks every body!

Following the rule offered by [Ben Boeckel](https://discourse.vtk.org/u/ben.boeckel), I have solved the problem.

A simple way is: move the lib with link error ahead in the link command , and you will finally get the right order.

Thanks again.

---

<div class="post-metadata">

### Author: ![guanrong](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/e9a140/32.png) [@guanrong](https://discourse.vtk.org/u/guanrong)
#### Post date: [July 26, 2022, 7:28am UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039/8 "2022-07-26T07:28:03Z")

</div>

Hi, Edward!  
I have the same problems as you got. And I have no idea about the rank levels of the all VTK static libraries. Can you tell me the method of making this ranking list?

Thanks!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [July 26, 2022, 1:41pm UTC](https://discourse.vtk.org/t/compile-error-when-use-vtk-static-library-in-qt-creator/1039/9 "2022-07-26T13:41:00Z")

</div>

The easiest is to just use CMake as it will order things properly. The most reliable way is to have CMake generate a project that links to the libraries you want and to grab the order from the link line.
