# How to build vtk

**URL:** https://discourse.vtk.org/t/how-to-build-vtk/2707
**Category:** Support
**Created:** [February 27, 2020, 7:04am UTC](https://discourse.vtk.org/t/how-to-build-vtk/2707 "2020-02-27T07:04:50Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![awa5114](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@awa5114](https://discourse.vtk.org/u/awa5114)
#### Post date: [February 27, 2020, 7:04am UTC](https://discourse.vtk.org/t/how-to-build-vtk/2707/1 "2020-02-27T07:04:50Z")

</div>

I would like to build vtk for two purposes:

- Run examples/come up with own examples in C++
- Contribute to development in case I find a bug or possible enhancement

So far I have gone through the following steps:

- Forked VTK to own GitLab account
- Did a `git clone own_account_url` on local machine
- Downloaded and installed CMake
- Downloaded and installed Mingw-w64 from [sourceforge](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download)
- added Mingw-w64 directory to PATH
- Created a `\bin` folder inside local clone of VTK repo
- Ran CMake with `.\vtk` as source folder and `.\vtk\bin` as binary folder, using Code Blocks Mingw generator

This seemed to work, generating a VTK.cbp file which I was able to open using CodeBlocks. I then built the project by hitting Ctrl+F9. After building for 40 minutes I got an error:

```auto
C:\Users\aboufira\AppData\Local\Temp\ccrGE4Ag.s: Fatal error: can't write 40 bytes to section .text of CMakeFiles\CommonCore.dir\vtkDataArray.cxx.obj: 'File too big'
C:/PROGRA~2/MINGW-~1/I686-8~1.0-P/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/as.exe: CMakeFiles\CommonCore.dir\vtkDataArray.cxx.obj: too many sections (42814)
C:\Users\aboufira\AppData\Local\Temp\ccrGE4Ag.s: Fatal error: can't close CMakeFiles\CommonCore.dir\vtkDataArray.cxx.obj: File too big
mingw32-make.exe[2]: *** [Common\Core\CMakeFiles\CommonCore.dir\build.make:996: Common/Core/CMakeFiles/CommonCore.dir/vtkDataArray.cxx.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:8126: Common/Core/CMakeFiles/CommonCore.dir/all] Error 2
mingw32-make.exe: *** [D:/github_projects/vtk/bin/Makefile:157: all] Error 2

```

Does anyone know why this occurs and how I can fix it? Thanks.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [February 27, 2020, 7:57am UTC](https://discourse.vtk.org/t/how-to-build-vtk/2707/2 "2020-02-27T07:57:18Z")

</div>

In order to build VTK, please follow the instructions here :  
[https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/build.md](https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/build.md)

You will notice that Mingw is not listed as a supported compiler.  
On windows we recommend visual studio + ninja. But pure visual studio is also supported.

Once you are able to build VTK, please follow this guide to be able to contribute :  
[https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/git/develop.md](https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/git/develop.md)

---

<div class="post-metadata">

### Author: ![awa5114](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@awa5114](https://discourse.vtk.org/u/awa5114)
#### Post date: [February 27, 2020, 8:23am UTC](https://discourse.vtk.org/t/how-to-build-vtk/2707/3 "2020-02-27T08:23:29Z")

</div>

Hi @mwestphal thanks for your response. I will probably continue with VS. Just out of curiosity though, the instructions state the following:

> Note that Unix-like environments such as Cygwin and MinGW are not officially supported

Does that mean these types of environments actually won’t work? If so why not? How is it that a valid .cbp file is generated with CMake?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [February 27, 2020, 8:29am UTC](https://discourse.vtk.org/t/how-to-build-vtk/2707/4 "2020-02-27T08:29:31Z")

</div>

They are not tested, so we assume they don’t work, but maybe they do.  
You will be on your own though, which I will not recommend as it looks like this is your first time compiling VTK.

As for the .cbp file, CMake doesn’t care that VTK is not supporting it officially.

If you are looking to work in a Unix-like environment, why not using Linux directly ?

---

<div class="post-metadata">

### Author: ![awa5114](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@awa5114](https://discourse.vtk.org/u/awa5114)
#### Post date: [February 27, 2020, 10:33am UTC](https://discourse.vtk.org/t/how-to-build-vtk/2707/5 "2020-02-27T10:33:51Z")

</div>

I see. No I’m not looking to work in a Unix-like environment as I use Windows. I was able to build the project again using CMake and now have a working VS2019 solution. A couple of follow up questions:

- Must I “build” the solution again under VS2019? Why is this not included in the steps listed in [https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/build.md](https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/build.md) ?
- I see `VTK_BUILD_TESTING` as one of the CMake variables. How is this different fron `VTK_BUILD_EXAMPLES`? How can I part or all of the test suite locally?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [February 27, 2020, 10:41am UTC](https://discourse.vtk.org/t/how-to-build-vtk/2707/6 "2020-02-27T10:41:20Z")

</div>

The visual studio only guide is here :  
[https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/build\_windows\_vs.md](https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/build_windows_vs.md)

VTK\_BUILD\_TESTING build the tests visible here : [https://www.cdash.org/CDash/index.php?project=VTK](https://www.cdash.org/CDash/index.php?project=VTK)  
VTK\_BUILD\_EXAMPLES build the examples : [https://lorensen.github.io/VTKExamples/site/](https://lorensen.github.io/VTKExamples/site/)

---

<div class="post-metadata">

### Author: ![awa5114](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@awa5114](https://discourse.vtk.org/u/awa5114)
#### Post date: [February 27, 2020, 11:57am UTC](https://discourse.vtk.org/t/how-to-build-vtk/2707/7 "2020-02-27T11:57:18Z")

</div>

Thanks. Those are good resources. I was able to successfully build the Release configuration (though it does take a while) and am now trying to “test with an example” as outlined by [https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/build\_windows\_vs.md](https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/build_windows_vs.md)

I do notice that the repository already contains an “Examples” directory, but that the examples in here do not correspond with the examples shown in [https://lorensen.github.io/VTKExamples/site/Cxx/](https://lorensen.github.io/VTKExamples/site/Cxx/)

Why are these examples different? Thanks.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [March 2, 2020, 6:36am UTC](https://discourse.vtk.org/t/how-to-build-vtk/2707/8 "2020-03-02T06:36:39Z")

</div>

VTK\_BUILD\_EXAMPLES build the example in the source, but the link I provided is more easy to navigate and copy examples from.
