VTK/Configure and Build: Difference between revisions
No edit summary |
No edit summary |
||
(11 intermediate revisions by 3 users not shown) | |||
Line 3: | Line 3: | ||
{{Welcome}} | {{Welcome}} | ||
'''<font color="green">This page is applicable | '''<font color="green">This page is only applicable to VTK 6, 7, and 8. More recent build instructions can be found at [https://gitlab.kitware.com/vtk/vtk/-/blob/master/Documentation/dev/build.md build.md]</font>''' | ||
This page describes how to configure and build VTK, with several popular options turned on. | This page describes how to configure and build VTK, with several popular options turned on. | ||
Line 9: | Line 9: | ||
=Prerequisites= | =Prerequisites= | ||
*The VTK build process requires [http://www.cmake.org CMake] version 2.8.8 or higher and a working compiler. On Unix-like operating systems, it also requires Make, while on Windows | *The VTK build process requires [http://www.cmake.org CMake] version 2.8.8 or higher and a working compiler. On Unix-like operating systems, it also requires Make, while on Windows we recommend Visual Studio (8 or later). | ||
*Building VTK with Qt is a common use case for the creation of nice user interfaces. Using Qt 4.8.* is recommended, but earlier versions and Qt 5.* are in various stages of support. Visit the [http://qt-project.org/downloads Qt download page] to get a copy of the source code or installer. Either the LGPL or commercial versions of Qt may be used. | *Building VTK with Qt is a common use case for the creation of nice user interfaces. Using Qt 4.8.* is recommended, but earlier versions and Qt 5.* are in various stages of support. Visit the [http://qt-project.org/downloads Qt download page] to get a copy of the source code or installer. Either the LGPL or commercial versions of Qt may be used. | ||
Line 45: | Line 45: | ||
<div style="clear: right; text-align: left; padding: .4em .9em .9em"> | <div style="clear: right; text-align: left; padding: .4em .9em .9em"> | ||
====On Windows==== | ====On Windows==== | ||
* Download the installer | * Download the installer [http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.exe CMake 2.8.12.2 installer] | ||
* Follow the installation instructions | * Follow the installation instructions | ||
====On Windows, if you are not administrator==== | ====On Windows, if you are not administrator==== | ||
* Download | * Download the [http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.zip CMake 2.8.12.2 binaries] | ||
* Uncompress into some directory | * Uncompress into some directory | ||
* Optional: create a shortcut on the desktop. | * Optional: create a shortcut on the desktop. | ||
Line 79: | Line 79: | ||
<div style="clear: right; text-align: left; float: right; padding: .4em .9em .9em"> | <div style="clear: right; text-align: left; float: right; padding: .4em .9em .9em"> | ||
====On Windows==== | ====On Windows==== | ||
To build CMake on windows, a previous version of CMake is required. This can be downloaded from the | To build CMake on windows, a previous version of CMake is required. This can be downloaded from the [http://www.cmake.org/HTML/Download.html CMake Download Page]. | ||
</div> | </div> | ||
Line 88: | Line 88: | ||
Download a VTK release from the [http://www.vtk.org/VTK/resources/software.html VTK Downloads page]. | Download a VTK release from the [http://www.vtk.org/VTK/resources/software.html VTK Downloads page]. | ||
==Checkout the VTK Repository with Git== | ==Checkout the VTK Repository with Git== | ||
If you want the nightly updates of VTK, this is your best bet. Checking out from source control also greatly facilitates the process of contributing back. Note that you may need to download and install a | If you want the nightly updates of VTK, this is your best bet. Checking out from source control also greatly facilitates the process of contributing back. Note that you may need to download and install a [http://git-scm.com/ git client]. | ||
{{Tip|Check out the [[VTK/Git | VTK Git landing page]].}} | {{Tip|Check out the [[VTK/Git | VTK Git landing page]].}} | ||
Line 156: | Line 156: | ||
===On Windows=== | ===On Windows=== | ||
* | * Start CMake from the Start menu | ||
* Make sure to select the appropriate source and the build directory. | * Make sure to select the appropriate source and the build directory. | ||
* Also, make sure to pick the appropriate generator. Some CMake versions will ask you to select the generator the first time you press Configure instead of having a drop-down menu in the main dialog. | * Also, make sure to pick the appropriate generator. Some CMake versions will ask you to select the generator the first time you press Configure instead of having a drop-down menu in the main dialog. | ||
[[Image:Vtk-cmake-gui.png|400px]] | [[Image:Vtk-cmake-gui.png|400px]] | ||
{{Tip|Uncheck BUILD_EXAMPLES and BUILD_TESTING to speed up the process significantly, if testing and examples are not important to you.}} | |||
===About CMake GUI=== | ===About CMake GUI=== | ||
Line 183: | Line 184: | ||
| bgcolor="#abcdef" height="8" | '''Description''' | | bgcolor="#abcdef" height="8" | '''Description''' | ||
|- | |- | ||
| BUILD_SHARED_LIBS || If ON, use shared libraries. This way executables are smaller, but you have to make sure the shared libraries are | | BUILD_SHARED_LIBS || If ON, use shared libraries. This way executables are smaller, but you have to make sure the shared libraries are available wherever your VTK based application runs. | ||
|- | |- | ||
| BUILD_TESTING || If ON, build the tests for submission to dashboards, or just run them locally with ctest -A | | BUILD_TESTING || If ON, build the tests for submission to dashboards, or just run them locally with ctest -A | ||
Line 197: | Line 196: | ||
| QT_QMAKE_EXECUTABLE || Path to Qt's qmake executable (such as /usr/local/bin/qmake). CMake uses this to locate the rest of the required Qt executables, headers and libraries. | | QT_QMAKE_EXECUTABLE || Path to Qt's qmake executable (such as /usr/local/bin/qmake). CMake uses this to locate the rest of the required Qt executables, headers and libraries. | ||
|} | |} | ||
=Configure with Qt= | =Configure with Qt= | ||
{{Note|This step is not absolutely necessary, but useful for anyone hoping to integrate VTK with Qt for a pretty graphical user interface. Depending on your platform and the desired Qt version, this can be a somewhat arduous process, especially if you need to build Qt from source. We recommend using Qt installers along the way whenever possible.}} | {{Note|This step is not absolutely necessary, but useful for anyone hoping to integrate VTK with Qt for a pretty graphical user interface. Depending on your platform and the desired Qt version, this can be a somewhat arduous process, especially if you need to build Qt from source. We recommend using Qt installers along the way whenever possible.}} | ||
Line 215: | Line 215: | ||
cmake -DQT_QMAKE_EXECUTABLE:PATH=/path/to/qt-4.8.6-build/qt-everywhere-opensource-src-4.8.6/bin/qmake \ | cmake -DQT_QMAKE_EXECUTABLE:PATH=/path/to/qt-4.8.6-build/qt-everywhere-opensource-src-4.8.6/bin/qmake \ | ||
-DVTK_Group_Qt:BOOL=ON \ | -DVTK_Group_Qt:BOOL=ON \ | ||
- | -DBUILD_SHARED_LIBS:BOOL=ON \ | ||
/path/to/VTK | /path/to/VTK | ||
}} | }} | ||
Line 283: | Line 283: | ||
}} | }} | ||
=Build VTK= | |||
After a successful configuration, it's time to build VTK. | |||
{{Tip|CMake generates the build files in a manner which makes it easy to use all processing cores on your machine. See the Kitware blog [http://www.kitware.com/blog/home/post/434 CMake: Building with all your cores].}} | |||
{| cellspacing="3" | |||
|- valign="top" | |||
|width="50%" class="MainPageBG" style="border: 1px solid #ffc9c9; color: #000; background-color: #fff3f3"| | |||
<div style="padding: .4em .9em .9em"> | |||
====On Unix-like operating systems==== | |||
Change into your designated build directory. There should be a file named Makefile. These make files have all dependencies and all rules to build VTK on this system. | |||
{{Warning|Do not try to move the build directory to another location on this system or to another system. The relevant paths are now hardcoded into the makefiles.}} | |||
Once you have Makefiles, you should be able to just type make in the build directory | |||
cd /path/to/VTK-build | |||
make | |||
* If you are on multi-processor system (let's say four processor), you can type: | |||
make -j4 | |||
</div> | |||
|width="50%" class="MainPageBG" style="border: 1px solid #c6c9ff; color: #000; background-color: #f0f0ff"| | |||
<div style="clear: right; text-align: left; padding: .4em .9em .9em"> | |||
====On Windows==== | |||
CMake will now create Visual Studio project files. You should now be able to open the VTK project (or workspace) file. Make sure to select the appropriate build type (Debug, Release, ...). To build VTK, simply build the ALL_BUILD target. | |||
[[Image:Vtk-msvc2010-annotation.png|400px]] | |||
</div> | |||
|} |
Latest revision as of 18:44, 25 August 2021
Introduction
Hello! Welcome to the wiki.
This page is only applicable to VTK 6, 7, and 8. More recent build instructions can be found at build.md
This page describes how to configure and build VTK, with several popular options turned on.
Prerequisites
- The VTK build process requires CMake version 2.8.8 or higher and a working compiler. On Unix-like operating systems, it also requires Make, while on Windows we recommend Visual Studio (8 or later).
- Building VTK with Qt is a common use case for the creation of nice user interfaces. Using Qt 4.8.* is recommended, but earlier versions and Qt 5.* are in various stages of support. Visit the Qt download page to get a copy of the source code or installer. Either the LGPL or commercial versions of Qt may be used.
Download And Install CMake
CMake is a tool that makes cross-platform building simple. If CMake does not exist on the system, and there are no pre-compiled binaries, use the instructions below on how to build it. Use the most recent source or binary version of CMake from the CMake web site.
Using Binaries
There are several precompiled binaries available at the CMake download page.
On Unix-like operating systemsLet's say on Linux, download the appropriate version and follow these instructions: cd $HOME wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2-Linux-i386.tar.gz mkdir software cd software tar xvfz ../cmake-2.8.12.2-Linux-i386.tar.gz
|
On Windows
On Windows, if you are not administrator
|
Build Your Own CMake
On Unix-like operating systemsDownload the source code: http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz cd $HOME wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz tar xzf cmake-2.8.12.2.tar.gz cd cmake-2.8.12.2 ./configure --prefix=$HOME/software make make install
|
On WindowsTo build CMake on windows, a previous version of CMake is required. This can be downloaded from the CMake Download Page. |
Download VTK Source code
Download a Release
Download a VTK release from the VTK Downloads page.
Checkout the VTK Repository with Git
If you want the nightly updates of VTK, this is your best bet. Checking out from source control also greatly facilitates the process of contributing back. Note that you may need to download and install a git client.
On Unix-like operating systemsPrepare directory for download # mkdir $HOME/projects # cd $HOME/projects To download the source code # git clone git://vtk.org/VTK.git # cd VTK To update the code # git fetch origin # git rebase origin/master |
On WindowsWe recommend msysgit. msysgit provides an msys shell that has the appropriate environment set up for using git and its tools. |
Configure VTK with CMake
- Always use a separate build directory. Do not build in the source directory.
On Unix-like systems
mkdir $HOME/projects/VTK-build cd $HOME/projects/VTK-build ccmake $HOME/projects/VTK About CCMake (Curses CMake GUI)
|
On Windows
About CMake GUI
|
VTK Settings
Variable | Description |
BUILD_SHARED_LIBS | If ON, use shared libraries. This way executables are smaller, but you have to make sure the shared libraries are available wherever your VTK based application runs. |
BUILD_TESTING | If ON, build the tests for submission to dashboards, or just run them locally with ctest -A |
CMAKE_BUILD_TYPE | Should be Release or Debug. If Debug, build with debug symbols. This will run more slowly, but will be more useful if you plan to use a debugger. |
CMAKE_INSTALL_PREFIX | Specifies where make should put the libraries when the make install command is run. |
TODO | Put the rest of the prominent variables here |
QT_QMAKE_EXECUTABLE | Path to Qt's qmake executable (such as /usr/local/bin/qmake). CMake uses this to locate the rest of the required Qt executables, headers and libraries. |
Configure with Qt
Qt 4.8.*
These notes should also work for 4.7.*, but we recommend using the latest 4.8.* release.
Qt5.*
Qt 5 comes with a few enhancements, among these the modularization of the code base, and the movement of all QWidget functionality into its own library. Qt5 also significantly improves the ease with which one can develop a custom interface. Users of Mac OS X will find better compiler support for the newer SDK's as well.
Build VTK
After a successful configuration, it's time to build VTK.
On Unix-like operating systemsChange into your designated build directory. There should be a file named Makefile. These make files have all dependencies and all rules to build VTK on this system. Once you have Makefiles, you should be able to just type make in the build directory cd /path/to/VTK-build make
make -j4 |