Preparing a build environment  


These notes detail how to create a development environment suitable for compiling the FSLView project. You may be able to download and install binary installations of some of these packages, however I have provided details of how to compile them from sources in case you don't have access to the pre-built versions.

Wherever possible I have provided instructions for performing an out-of-source build, i.e., a build in a separate directory from the source directory. This is desirable because it allows you to re-build with various different switches from the same source tree, e.g., maintaining separate debug and optimised builds. At FMRIB we build all releases of FSLView, each supported architecture with both debug and release flags, from a single shared source directory. When this works it is very useful and FSLView is intended to build this way.

On my systems the packages are all installed into their own directory within /usr/local so that we can test/install different versions. You don't need to do this but it'll make following the instructions easier if you do.


Dependencies

The following packages are required to build FSLView:

Package nameVersionNotes
BOOST1.33.1Probably any version above 1.29 (first one I tried) will do.
Qt3.1.x-3.3.xOn my systems the uic compiler messes up the icons for qt < 3.3
Qwt4.2.0
CMake2.2-patch 3
VTK5.05.1 also works
FSL3.3.x

Platform Notes

MacOSX: Leopard (version 10.5) is not supported by Trolltech for Qt 3.x variants - Qt 3.x was end-of-lifed in July 2007. We are quite likely to be porting to Qt 4.x soon but until that time you will need to obtain Tiger (10.4) binaries on Leopard machines.


Configuring and building the dependent packages

CMake

A word about CMake

This package performs a wide range of build configuration tasks which are difficult to achieve with other systems (including the popular automake and autoconf tools). I appreciate that this requires the build of yet another package but the pros far outweigh the cons. In the near future I hope to convert all FSL development to use CMake and we will probably bundle a compatible version with the basic FSL distribution.

Download from CMake download page and unpack into your source directory.

Configure and build as follows:

cd CMake
mkdir build
cd build
../configure
make
make install

Platform Notes

MacOSX: Libraries created using the switch: -install_name @executable_path/../Frameworks/ can be copied into the FSLView.app/Contents/Frameworks subdirectory creating a relocatable bundle. To get CMake to build libraries this way modify the /usr/local/share/CMake/Modules/Platform/Darwin.cmake file with the following patch:

cd /usr/local/shared/CMake/Modules/Platform
patch -i cmakepatch.txt

Configure cmake projects without rpath support, i.e. CMAKE_USE_RELATIVE_PATHS=OFF.

BOOST

Download from boost.org and unpack into /usr/local/boost

We're only using some of the template classes from boost so we don't need anything but header files, therefore, you don't need to compile boost.

Qt

Important: You may well have qt already installed on your machine. Most Linux distributions ship with Qt to support the popular KDE windowing system. If it's already on your system then I recommend you try using that version before installing from scratch. If you decide to do this then you will need to change QTDIR in all the subsequent builds accordingly.

Warning: Qt can take a very long time to compile. You can speed things up a little by editing the "Makefile" file in the distribution top-level source directory and removing the sub-tutorial and sub-example references from the "all:" target; however, even on the fastest machines at my disposal, it still takes hours to build.

Important: When building Qt you must ensure that other installations of Qt aren't pathed in. In particular it can ruin the installation if an old qt/lib directory is used by the qt tools during the build.

Download from Trolltech Qt Site and unpack into your source directory.

Configure and build as follows:

cd /home/builds; mkdir qt; cd qt
export QTDIR=`pwd`
export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=`pwd`/lib:$DYLD_LIBRARY_PATH
/home/sources/qt-mac-free-3.3.6/configure -prefix /usr/local/qt -fast -thread
make
make install

Platform notes

MacOSX: Currently a bug in the build means that it will fail due to a missing Info.plist file. I have been restarting the build at that point to complete the rest of the compilation.

MacOSX: As with CMake you need to modify the link stages if you want to make relocatable .app bundles. (Un)comment the relevant lines in mkspec/macx-g++/qmake.conf and/or mkspec/darwin-g++/qmake.conf configuration before building.

MacOSX X11 (untested): Set MAKESPECS to "darwin-g++" to enable building with X11 support.

Qwt

Download from Qwt Sourceforge and unpack into your source directory.

Bizarely Qwt doesn't have an "install" target for its main components (only for the plugin!) so I add one to /home/sources/qwt-4.2.0/qwt.pro as follows:

cat >> qwt.pro
INSTALLBASE    = /usr/local/qwt
target.path    = $$INSTALLBASE/lib
headers.path   = $$INSTALLBASE/include
headers.files  = $$HEADERS
INSTALLS       = target headers

Configure and build as follows:

export QTDIR=/usr/local/qt
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$QTDIR/lib:$DYLD_LIBRARY_PATH
cd /home/builds; mkdir qwt; cd qwt
qmake /home/sources/qwt-4.2.0/qwt.pro
make
make install
mkdir designer; cd designer
qmake /home/sources/qwt-4.2.0/designer/qwtplugin.pro
make
make install

VTK

Download from VTK download page and unpack into your source directory.

Configure and build as follows:

export QTDIR=/usr/local/qt
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$QTDIR/lib:$DYLD_LIBRARY_PATH
cd /home/builds; mkdir vtk; cd vtk
export QTDIR=/usr/local/qt
cmake /home/sources/VTK \
  -DCMAKE_INSTALL_PREFIX=/usr/local/vtk -DCMAKE_BUILD_TYPE=Release \
  -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON \
  -DVTK_USE_GUISUPPORT=ON -DVTK_USE_QVTK=ON
make
make install