Installation of VTK in Linux and Windows-general Linux technology-Linux programming and kernel information. For details, refer to the following section. I. Brief Introduction
VTK (Visualization Toolkit) is a Visualization Toolkit for secondary development. It has the most influence in similar products in the world and can basically be used as a specification in the field of Visualization.
History and status quo of VTK:
In December 1993, GE's Will Schroeder and Ken Martin both wrote a book: The Visualization Toolkit: An Object-Oriented Approach to 3D Graphics, and VTK was given away as The supporting software for this book. Due to the outstanding performance of VTK, people are far more concerned with the software than books, and VTK has a huge user base in less than a few years. VTK is now maintained by kitware and developed in the form of open source. Everyone in the world can join the ranks of developers. Currently, the stable version of VTK is 5.0, and the version of nightly is updated every day.
VTK features: Open Source. Use the CVS version to control cross-platforms. Supports Windows, Unix, Linux, Mac, and other platforms with powerful functions. Suitable for almost all visualization fields, from medical visualization to data visualization, VTK users can be found to support multi-language development. Needless to say, the C language also includes scripting languages such as TCL and Python. It also supports a powerful development team in Java. Including multiple development units with commercial maintenance and intellectual resources from users all over the world :)
2. Preparations before installation
Because VTK is open-source, we can get its source code from the official website. Because it is cross-platform, we need to pack the source code, can be accepted by gcc vc6.0 and other compilers. The cross-platform tool used by VTK is CMake, which is also a product of kitware and can be obtained from the official homepage.
Many people do not know what cmake is. I want to explain it here. The vtk source code we downloaded is written in c ++ and is a big project. No matter what platform or compiler we use, you need to tell the compiler how to compile such a huge object. The project file is the general structure of the project. For example, the dsw file is under vc6.0, and makefile can be seen as such in gcc. These engineering systems tell the compiler what to do and what parameters are needed. Well, cmake is a tool used to generate engineering files suitable for different compilers. Then, we cannot use cmake. Someone may ask, can I compile vtk without cmake? Of course you can. For example, in vc, you can create a new project, add files one by one, and add compilation options by yourself. in linux, you can write makefile by yourself, of course, this method is almost impossible to implement. Even if it is implemented, there will be a lot of trouble in the future development process. So use cmake!
Before installation, you need to get the following file in the http://vtk.org/get-software.php, I here to vtk5.0 as an example, in winxp + vc6.0 and linux + gcc implementation
Linux:
Pre-install gcc3.0
Vtk-5.0.0.tar.gz vtk source code
Data required for the vtkdata-5.0.0.tar.gz vtk example
Cmake-2.4.3-Linux-i386.tar.gz cmake program, now download from the official website, is not compiled
Windows:
Pre-install vc6.0
Vtk-5.0.0.zip vtk source code
Data required for the vtkdata-5.0.0.zip vtk example
CMSetup243-win32.exe cmake Installer
In different systems above, the vtk source code and data are actually the same, but different packaging tools are used. In addition, the cmake version is determined by the vtk version. For example, the minimum cmake version required by vtk5.0 seems to be 2.0. Here we simply use the updated version 2.4.
Iii. Install vtk in windows
1. Install cmake
It should be easy to install software in windows. Run cmsetup243-win32.exe and keep clicking Next.
2. decompress the two packages and create the required folder.
I do not like to Compile directly in the source code, but create another bin folder. For example, I used c: \ vtk \ as our main directory, decompressed the vtk source code to the vtk5.0 folder, and decompressed the data to the vtkdata folder, create an empty folder named bin. Note: Under. \ vtk5.0, there should be a lot of folders and files, and several subfolders can be found under. \ vtkdata.
3. Run cmake
First, add the source code and compilation working directory. In this example, the sourse code directory is c: \ vtk \ vtk5.0 \, And the build directory is c: \ vtk \ bin \. Then press the configure button, and the cmake software will let you select the compiler to use. Here we select vc6.0, and then cmake will scan the system. After stopping, we can modify the cmake option.
Modify the cmake option. This step is really hard to say. Generally, vtk beginners only need to use the default settings. I will only remind you of some important options:
Build_examples
Build_testing: test code is some test code used by vtk developers to test vtk code. We often regard them as examples of learning vtk. Similar to build_examples, whether to compile them depends on your preferences.
Build_shared_libs: if it is set to off, only the lib file will be generated, which is enough for development. If it is set to on, multiple dll files are generated. The difference is not clearly stated here. If static library programming is used, the application can run independently and the size is large. If dynamic library programming is used, the application must find a dynamic library to run, but the size can be relatively small
Cmake_install_prefix: it is important to install the vtk path later. Some people may ask, after compilation, can I use vtk? Why should I install it? Yes, no installation is actually acceptable. The advantage of installation is that you can extract the. h. lib. dll and other excellent files from over 1 GB, install them in the specified directory, and modify the system environment variables.
Vtk_data_root: Generally, cmake can find the vtkdata path by itself, but if not, fill in c: \ vtk \ vtkdata \ To tell cmake where the data required by vtk is
Vtk_use_parallel: If you want to use vtk for parallel computing, choose this option. If you only want to learn vtk, keep the default off.
Vtk_use_guisupport: Many people have installed vtk but cannot run examples of Mixed Programming with mfc in vtk. The error message is that vtkmfc is missing. lib, the problem lies in this option. We must set it to on. After configure again, a new option "vtk_use_mfc" will appear and set it to on.
Tip: In cmake, some options depend on other options, such as vtk_use_guisupport and vtk_use_mfc. When we disable vtk_use_guisupport, vtk_use_mfc cannot be seen.
After the cmake option is modified, click the configure button until no options are displayed in red. At this time, the OK button is available. Click OK to generate the vc project file.
4. Compile with vc6.0
Use vc6.0 to open the vtk. dsw file in the bin directory. Because there are many files, the opening speed may be slow. After opening, build directly. The Compilation Time is related to the computer performance and some cmake options, which can be completed within one hour. The result is saved in the. \ bin directory. If compilation fails, check the Error Type prompted by the compiler to handle it!
5. Installation
Use vc6.0 to open the install. dsp file in the bin directory, so you can directly build the file without worrying about the error. The compilation result will be installed in the directory set by cmake_install_prefix. Delete the c: \ vtk directory. Of course, it is recommended to retain the cmake option. You may need to change the cmake option later to fix the compilation again. Cmake checks the changes and only processes the changes. if no changes are made, do not recompile them.
4. Install vtk in linux
Installation in linux is the same as installation in windows. I assume that you are familiar with basic operations in linux.
1. Install cmake
The cmake file downloaded from the official website is free of compilation. You can find the executable file ccmake in the bin folder of the cmake source code. If you haven't compiled it, compile it yourself. In addition, it is best to add the ccmake command to the system's searchable range so that you can directly run the ccmake command. I will directly use # apt-get install cmake here and it will be OK.
2. decompress the two packages and create the required folder.
For installation in the same window, specify a main directory, such ~ /Vtk/, create three folders and unpackage.
3. cmake
Cd ~ /Vtk/bin/
Ccmake.../vtk5.0
For more information about how to modify cmake options, see the previous vtk installation in windows. Because cmake in linux is a text interface, it is not intuitive to operate and has few functions.
4. Compile
Cd ~ /Vtk/bin/
Make
The make command can be viewed as a gcc compiler that calls the makefile file for compilation.
5. Installation
Cd ~ /Vtk/bin/
Sudo make install
Sudo is used because the root permission is required for reading and writing some files.
V. Summary
The best tutorial for learning vtk is the vtk user guide. The best solution is to make good use of search.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.