Compiling Fox on Linux
Compiling F.O.X. under Linux is normally easy (it was originally developed using Linux). The source code for Fox now auto-downloads the wxWidgets and freeglut libraries, so dependencies should be minimal. As always, send me an email at email@example.com if you have any trouble with the installation.
Installing the required graphics libraries
Below are specific instructions to install the required graphics libaries for the following distributions :
Please add or correct the instructions for your distribution...
If your distribution is not listed, just follow the general building instructions.
General Instructions (if your distribution is not listed below)
To install F.O.X. under Linux:
You will need valid libraries and development files for OpenGL. You may require a specific library for your card (NVidia,...), the Xfree-devel or libxorg-devel, and the gtk-devel (or gtk+-devel or gtk2-devel...) packages. For all major distributions, these packages are included either in the default install or as an additionnal package.
- Fox can be built by downloading and statically linking the required following libraries, but it is of course much simpler to install them from the available distribution packages:
This is partially a guess since I do not have this distribution, so feel free to correct these
Fedora Core 3 & 4
Development packages: gcc gcc-c++ gcc-g77
Graphics development package : xorg-x11-devel, gtk+-devel
Debian, Ubuntu or Linux Mint
(as of 2015)
Development packages: gcc g++
Graphics development package : libwxgtk3.0-dev, libwxgtk3.0-0, freeglut3, freeglut3-dev
- Note that wxWidgets (wxGTK) should be at least version 3.0.2 - otherwise do not use 'shared=1' or 'shared-wxgtk=1' compiling option, and let Fox download wxGTK for compilation.
Required librairies: libnewmat, libnewmat-dev, fftw3, fftw3-dev, cmake`
Get Fox (sourceforge)
Get the Fox.tar.bz2 from SourceForge
tar -xjf Fox-VERSION.tar.bz2
Get Latest Fox from git repository (RECOMMENDED)
git clone https://github.com/vincefn/objcryst.git mv objcryst Fox cd Fox/ObjCryst ln -sf rules-gnu.mak rules.mak cd ../Fox ln -sf gnu.mak Makefile
Compile & install Fox
To compile and install Fox, go to the Fox/Fox subdirectory (or Fox-VERSION/Fox/), and then type:
make shared=1 # See note below about shared libraries options sudo make install #(for this last step you must be root).
Note: there are several options for the make command:
If fftw, wxgtk (>=3.0.2), freeglut or newmat are already available as shared libraries on your computer, you can use them without recompiling them. You can just append "shared-wxgtk=1", "shared-glut=1", "shared-fftw=1" and "shared-newmat=1". If you have all five shared libraries (as possible for Debian and Ubuntu), just use "shared=1". Examples:
make shared-wxgtk=1 shared-glut=1 shared-fftw=1
Fox will be installed in /usr/local/bin/Fox. Otherwise the compiled file is in the src/Fox subdirectory.
Note: if during the early stages of the compilation (when freeglut is compiled), you get an error message about libGL.la, this can mean that libGL.la is not in the same directory as other x11 libraries. On my computer, where libGL.la is provided by the nVidia installer, I needed to do "ln -s /usr/lib/libGL.la /usr/X11R6/lib/".
Compiling a version of Fox without GUI (Fox-nogui)
It is possible to compile a version of Fox that does not use a GUI and can only be used from the command-line. This is useful if you want to use Fox on a cluster. To do that just you just need to compile the Fox-nogui target:
tar -xjf Fox-VERSION.tar.bz2 cd Fox-VERSION cd Fox make Fox-nogui shared=1
The resulting application is src/Fox-nogui.
Note that when switching from building Fox to building Fox-nogui (and vice-versa) you must do a make tidy first.
Compiling an optimized version of Fox
The first set of optimizations can be activated by using processor-specific optimizations. If you edit the Fox/ObjCryst/rules.mak file, and search for the part where the CPPFLAGS are defined:
CPPFLAGS = -O3 -w -ffast-math -fstrict-aliasing -pipe -fomit-frame-pointer -funroll-loops
Auto-vectorization: starting with gcc 4.0.0, it is possible to automatically vectorize some loops: append -ftree-vectorize to the CPPFLAGS options to do that (see the examples commented out in the rules.mak file).
Profile driven optimizations
Fox can be further optimized by making "test runs" which are used to give hints to the compiler on how to best optimize the code. To do this you (i) compile Fox by enabling the "recording" of the optimization, then (ii) you run a few optimizations, then (iii) you recompile using the recorded profile. This requires gcc version 3.2 or above.To do that from the Fox subdirectory, do:
make clean make Fox profile=2 src/Fox --nogui example/pbso4-joint.xml --randomize -n 50000 -o /dev/null src/Fox --nogui example/Cimetidine-powder.xml --randomize -n 50000 -o /dev/null src/Fox --speedtest make clean make Fox profile=3 make install
This yields about 10% faster code.
If you also launch the Fox GUI and do a profile-fitting (between the 'profile=2' and 'profile=3' compilations), this will also accelerate profile fitting and least squares operations.