Cross compiling ParaView3 and VTK
To cross compile ParaView3 and/or VTK you need ParaView3/VTK from cvs and cmake cvs (as of July 2007). The process of crosscompiling VTK is similar to the process of crosscompiling ParaView, so I'll focus on ParaView3, but it can be applied just the same way to crosscompiling VTK.
At first you need to set up the required cross compiling toolchain, how this is done is described here.
You will need an installation directory for all your cross compiled software, a good choice might be $HOME/bgl-install/ .
Building Mesa
If the target system doesn't have any OpenGL libraries or Mesa already installed, or if it doesn't has any display capabilities at all, you need to install the Mesa libraries, which offer an OSMesa component, the Offscreen-Mesa, so that the rendering goes into a memory buffer. You can get the Mesa sources from http://www.mesa3d.org, the download section is at http://sourceforge.net/project/showfiles.php?group_id=3 .
Building Mesa 7.0.1 or newer for BlueGene
Starting with version 7.0.1 building Mesa for BlueGene with the GNU toolchain nis supported out of the box.
All you have to do is to adjust the installation directory, this is done by modifying the INSTALL_DIR in configs/default, otherwise the cross compiled mesa will be installed to /usr/local/, which doesn't make sense. So search the entry for INSTALL_DIR and modify it to something like this:
# Installation directories (for make install) INSTALL_DIR = /your/home/dir/bgl-install
Then you can simply build and install it. For building Mesa you need to call make with the configuration you want, so for BlueGene it looks like the following:
$ make bluegene-osmesa $ make install
For similar systems it is probably the easiest way to reuse the bluegene-osmesa configuration file and adjust it to the specific system (e.g. using the right compiler).
If you want to use the IBM xlc toolchain support for this will be included in the next Mesa release, i.e. Mesa > 7.0.1, or you can get it now from the Mesa git repository: http://www.mesa3d.org/, follow link "Source code repository". The configuration name for this is "bluegene-xlc-osmesa".
Building Mesa 7.0.1 or newer for Cray Xt3/Catamount
You can build Mesa for Catamount using the Portland Group toolchain, but you have to modify one of the Mesa configuration files accordingly, e.g. configs/bluegene-osmesa:
# Configuration for building only libOSMesa on BlueGene, no Xlib driver # This doesn't really have a lot of dependencies, so it should be usable # on other (gcc-based) systems too. # It uses static linking and disables multithreading. include $(TOP)/configs/default CONFIG_NAME = bluegene-osmesa # Compiler and flags CC = cc CXX = CC CFLAGS = -target=catamount -O3 -fPIC -fastsse -Mnontemporal -Mprefetch=distance:8,nta -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE CXXFLAGS = -target=catamount -O3 -fPIC -fastsse -Mnontemporal -Mprefetch=distance:8,nta -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURC MKLIB_OPTIONS = -static OSMESA_LIB_NAME = libOSMesa.a # Directories SRC_DIRS = mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = osdemos # Dependencies OSMESA_LIB_DEPS = -lm GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
Then you can build it with "make bluegen-osmesa". Once this is tested that the resulting library actually works, please submit the configuration to mesa3d-dev@lists.sourceforge.net so it will be included in the official Mesa releases (or let me know so I will do it, Alex).
Mesa 7.6.1 Cray XT4 Compute Node Linux (CNL)
Change the compiler lines in $MESA_SRC/config/linux-osmesa-static to read as follows:
CC = cc CXX = CC
- make linux-osmesa-static
- make install DESTDIR=/my/install/dir
Building Python
Go to this page for information how to build Python with CMake. This includes instruction for building Python for IBM BlueGene/L and Cray Xt3/Catamount.
CMake
Cray XT4
copy CRAYXT_COMPUTE_LINUX.cmake to $cmake_install_dir/share/cmake2.x/Modules/Platform/
#CRAYXT_COMPUTE_LINUX.cmake contents #Compute Node Linux, which runs on the compute nodes of Cray XT machines SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty\ SET(CMAKE_LINK_LIBRARY_SUFFIX "") SET(CMAKE_STATIC_LIBRARY_PREFIX "lib") SET(CMAKE_STATIC_LIBRARY_SUFFIX ".a") SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib SET(CMAKE_SHARED_LIBRARY_SUFFIX ".a") # .a SET(CMAKE_EXECUTABLE_SUFFIX "") # .exe SET(CMAKE_DL_LIBS "" ) SET(CMAKE_FIND_LIBRARY_PREFIXES "lib") SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") INCLUDE(Platform/UnixPaths) SET(CMAKE_CXX_LINK_SHARED_LIBRARY) SET(CMAKE_CXX_LINK_MODULE_LIBRARY) SET(CMAKE_C_LINK_SHARED_LIBRARY) SET(CMAKE_C_LINK_MODULE_LIBRARY)
Toolchains for crosscompiling
XT4
Following is the contents of a toolchain file:
# the name of the target operating system SET(CMAKE_SYSTEM_NAME CRAYXT_COMPUTE_LINUX) # set the compiler set(CMAKE_C_COMPILER cc -target=linux) set(CMAKE_CXX_COMPILER CC -target=linux) # set the search path for the environment coming with the compiler # and a directory where you can install your own compiled software set(CMAKE_FIND_ROOT_PATH /opt/xt-pe/default /opt/mpt/3.5.0/xt/mpich2-gnu/ /ccs/proj/paraview/paraview/ ) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search # programs in the host environment set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
compilers
cc and CC are the wrapped versions of the compiler on the front end nodes to build for the back end nodes. The wrapping can be seen by doing a cc -v or CC -v. The wrappings contain the correct directories and libraries for mpi and cpu optimization.
CMAKE_FIND_ROOT_PATH
The directories listed here will be part of the search path for includes and libraries. These ROOT_PATHS will contain lib and include directories that will get searched. Therefore things like $MPI_HOME would be listed here allowing cmake to find the mpi libraries on it's own.
TryRunResults
Building ParaView/VTK
Building a native ParaView
When building ParaView, some executables are executed which are built during the same build. Since the executables built for the target platform (generally) cannot run on the build host, two build trees are required, a native buildtree and the cross compiling build tree.
~/src/ $ cd ParaView3 ~/src/ParaView3/ $ mkdir build-native ~/src/ParaView3/ $ mkdir build-bluegene
Make sure you turn all required options in build-native, e.g. if you need Python wrapping for the target platform you also need to enable Python wrapping in build-native/.
At first build the native version. If you don't need the Qt GUI, disable the option PARAVIEW_BUILD_QT_GUI. Using ccmake is recommended, there it is much easier to adjust the options than using cmake only.
~/src/ParaView3/build-native $ ccmake .. ... ~/src/ParaView3/build-native $ make ... ~/src/ParaView3/build-native $
Building ParaView for a target platform which is already supported
In cross compiling mode, ParaView loads the package ParaView3CompileTools via FIND_PACKAGE(ParaView3CompileTools REQUIRED). To find the package "ParaView3CompileTools", the ParaView3CompileTools_DIR variable has to be set to the build directory of the native build. In this directory a file named ParaView3CompileToolsConfig.cmake has been created during the build.
If you run CMake for cross compiling, it will finish with several error message, one for each TRY_RUN() which was found during the CMake run. When cross compiling the cross compiled executables usually can't run on the build host, so TRY_RUN() can't work. Instead the results for the TRY_RUN() commands have to be filled in manually. If you are building ParaView for BlueGene, this has already been done for you and you can just use the results:
~/src/ParaView3/build-bluegene $ ccmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-BlueGeneL-gcc.cmake -DParaView3CompileTools_DIR=~/src/ParaView3/build-native -C ~/src/ParaView3/CMake/TryRunResults-ParaView3-bgl-gcc.cmake .. ...
You can build ParaView also using the IBM xlc toolchain, you just need to replace TryRunResults-ParaView3-bgl-gcc.cmake with TryRunResults-ParaView3-bgl-xlc.cmake and specifiy a toolchain file for xlc instead gcc. The next step is to select the desired options in ccmake. If you want Python wrapping, but don't need a GUI, select the following options using ccmake:
- PARAVIEW_BUILD_QT_GUI: OFF
- PARAVIEW_ENABLE_PYTHON: ON
- PARAVIEW_USE_MPI: ON
E.g. on BlueGene make sure the following options are already set as shown below, this should happen automatically:
- VTK_OPENGL_HAS_OSMESA: ON
- VTK_NO_PYTHON_THREADS: ON
- BUILD_SHARED_LIBS: OFF
Building ParaView for Cray Xt3/Catamount
This is work in progress. Most things are similar to BlueGene, no shared libs, multithreading etc. So to get it build the file ParaView3/CMake/TryRunResults-ParaView3-bgl-gcc.cmake can be used here to for the beginning. The big difference is that Catamount doesn't support any sockets. You can find information about building software for Catamount with CMake on http://www.cmake.org/Wiki/CmakeCrayXt3 , including the required toolchain file.
Important: make sure you build ParaView with the same toolchain as you used for Mesa (i.e. PGI), otherwise there will be conflicts at least with -lm.
So basically you do the same thing as for BlueGene:
~/src/ParaView3/build-catamount $ ccmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchains/Toolchain-Catamount.cmake -DParaView3CompileTools_DIR=~/src/ParaView3/build-native -C ~/src/ParaView3/CMake/TryRunResults-ParaView3-bgl-gcc.cmake .. ...
- Additionally the CMake option VTK_USE_METAIO (not METAIO_FOR_VTK !) has to be disabled.
In VTK/Parallel/VTKParallelCMakeTests.cmake there is now a cmake variable HAVE_SOCKETS, which is set to FALSE for Catamount. This is used to define a macro when building vtkSocket.cxx to skip the implementation and just return failure from all methods. This will allow applications that use sockets to link. At least non-sockets features of the applications will work.
There is a problem with large file support, dirent and readdir for Catamount, readdir is #defined to readdir64 if large file support is enabled, but dirent is still dirent and not dirent64. I inserted the following code once in kwsys/Directory.cxx and additionally in some more files in ParaView/VTK/. I guess that's not the best way to deal with this problem:
/* There is a problem with the Portland compiler, large file support and glibc/Linux system headers: http://www.pgroup.com/userforum/viewtopic.php?p=1992&sid=f16167f51964f1a68fe5041b8eb213b6 */ #if defined(__PGI) && defined(__USE_FILE_OFFSET64) # define dirent dirent64 #endif
Building ParaView for a new target platform
In the case you are cross compiling ParaView for a platform where there are no TryRunResults in ParaView/CMake/ you need to create this file yourself. This works as follows:
~/src/ParaView3/build-myplatform $ ccmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-MyPlatform-gcc.cmake -DParaView3CompileTools_DIR=~/src/ParaView3/build-native .. ...
You can do this in ccmake, but there is a better way. CMake will have created a file ${CMAKE_BINARY_DIR}/TryRunResults.cmake. This is a CMake script which already contains SET() commands for all required variables which TRY_RUN() couldn't figure out, accompanied by quite verbose comments which should help you in figuring out the correct results for the target platform. Copy this file to a save location (i.e. outside the build dir) and edit it:
~/src/ParaView3/build-myplatform $ cp TryRunResults.cmake ../ParaView3-MyPlatform-TryRunResults.cmake ~/src/ParaView3/build-myplatform $ edit ../ParaView3-MyPlatform-TryRunResults.cmake ~/src/ParaView3/build-myplatform $ ccmake -C ../ParaView3-MyPlatform-TryRunResults.cmake . ... ~/src/ParaView3/build-myplatform $ make ...
The variables are:
- CMAKE_REQUIRE_LARGE_FILE_SUPPORT ; enter 1 if your system doesn't have problems with large files
- CMAKE_REQUIRE_LARGE_FILE_SUPPORT__TRYRUN_OUTPUT ; unused, ignore it
- SHARED_LIBRARY_PATH_TYPE ; unused, set it to 0
- SHARED_LIBRARY_PATH_TYPE__TRYRUN_OUTPUT ; enter the name of the environment variable on the target platform, which sets the search path for shared libraries, e.g. LD_LIBRARY_PATH on Linux . If the target system doesn't have shared libraries, set it to "".
- VTK_TYPE_CHAR_IS_SIGNED ; if a char is signed by default on the target platform, enter 1 here, otherwise 0
- VTK_ANSI_STREAM_EOF_RESULT ; if the stream library doesn't have bugs, enter 0 here, otherwise check VTK/CMake/vtkTestStreamEOF.cxx
- KWSYS_LFS_WORKS ; if large file support doesn't have problems, enter 0 here
- KWSYS_LFS_WORKS__TRYRUN_OUTPUT ; unused, ignore it
- HDF5_PRINTF_LL_TEST_RUN ; set it to 0
- HDF5_PRINTF_LL_TEST_RUN__TRYRUN_OUTPUT ; set it to "PRINTF_LL_WIDTH=[ll]" , where "ll" is the printf format option for 64 bit integers
As in the example shown above, you use this file to preload the cmake cache.