Hello. In this short post I will explain how to build static libraries of VTK.
Main reason why it needs: Because official “How to” has just 2 lines without any explanations. And by default will be builded dynamic libraries. With which I had a problem like link to vtkCocoaGLView was not found, but it actually was in a library.
Let’s start. You will need CMake to build and VTK sources.
- Launch CMake from your Application folder. In main menu go to “Tool” -> “Install for Command Line Use”, in case if you did not install yet.
- Unpack VTK to some directory, working place.
- Enter to VTK directory and create directory with name build
Now you can configure and generate makefile or Xcode project file from console or User interface of CMake application.
If you would like to build with makefile in terminal go to next steps, if not jump to Build with Xcode section.
Build in Terminal
- Open Terminal.
- Go to build directory of VTK.
Copy and past next line:
1
|
ccmake .. -G "UNIX Makefiles" -DVTK_USE_QVTK:BOOL=ON -DVTK_USE_COCOA:BOOL=ON -DVTK_USE_CARBON:BOOL=OFF -DCMAKE_OSX_ARCHITECTURES:STRING=x86_64 -DCMAKE_INSTALL_PREFIX=/path/to/folder -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS:BOOL=OFF
|
Note: Path to directories should be full without “~”.
If you change your mind about makefile and Xcode, so you can easily replace “UNIX Makefiles” on “Xcode”. In result you will get Xcode project.
- DVTK_USE_COCOA and DVTK_USE_CARBON
Choose on of UI’s, Cocoa or Carbon. Better for latest Mac OS X applications is Cocoa.
- DCMAKE_OSX_ARCHITECTURES
In my case it’s just x86_64, but if you need i386 as well, just replace x86_64 on “i386;x86_64″
- DCMAKE_INSTALL_PREFIX
Folder to which will be copied result libraries and headers. Create some folder to which you would like install. Or install to system /usr/local.
With this option says build dynamic = ON or static = OFF
- DBUILD_SHARED_LIBS
For deployment target, for example 10.7:
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7
Press enter and you will see configuration panel:
1. press c on keyboard and wait until finish. If it’s shows error, press e and press c again.
2. press g
3. check if “Makefile” was generated and located in build directory
4. build with command “make -j 4″, 4 – is number of threads which you want to use.
5. and final “make install”
Build with Xcode
1. Open CMake application
2. write path to sources code
3. write path to build directory which is located in VTK source folder
4. press “Generate” button and choose “Xcode” option
5. turn on “Advanced” checkbox
6. find and specify next options:
VTK_USE_COCOA – yes
VTK_USE_CARBON – no
BUILD_SHARED_LIBS – no
CMAKE_OSX_ARCHITECTURES – i386;x84_64
7. press Generate button
Note: if you have got *.dylib dynamic libraries in product of Xcode project. Delete generated Xcode project and press Configure and Generate buttons again.
Now you can open Xcode project and build libraries.
Text got quite big, so in next post I will show example of VTK usage. Or you can go to Example directory and try to launch something by yourself if can’t wait. :)
Enjoy!
UPD: One more think. In configuration you can choose Qt UI, VTK_Group_Qt. A bit old tutorial, I will try to do it late.