|
| 1 | +.. _compile_linux: |
| 2 | + |
| 3 | +Compiling Fox under Linux |
| 4 | +========================= |
| 5 | + |
| 6 | +Requirements |
| 7 | +------------ |
| 8 | +To install F.O.X. under Linux, you will need: |
| 9 | +* standard development packages (gcc,..) |
| 10 | +* OpenGL development libraries, e.g. `libopengl-dev` |
| 11 | + |
| 12 | +You will also need more specific dependencies: |
| 13 | +* wxGTK (>=3.0.2) |
| 14 | +* newmat |
| 15 | +* freeglut |
| 16 | +* fftw3 (development library) |
| 17 | + |
| 18 | +Not that the latter can be automatically donwloaded and linked statically as part of the Fox installation, |
| 19 | +but you can use the system libraries when they are available. |
| 20 | + |
| 21 | +Debian/Ubuntu |
| 22 | +^^^^^^^^^^^^^ |
| 23 | +Install the following packages (22.04): ``gcc g++ libwxgtk3.0-gtk3 ibwxgtk3.0-gtk3-dev freeglut3 freeglut3-dev`` |
| 24 | + |
| 25 | +Download Fox |
| 26 | +------------ |
| 27 | +Fox release from github |
| 28 | +^^^^^^^^^^^^^^^^^^^^^^^ |
| 29 | +Get the Fox.tar.bz2 from `GitHub <https://github.com/vincefn/objcryst/releases>`_, |
| 30 | +and uncompress: |
| 31 | + |
| 32 | +.. code-block:: shell |
| 33 | +
|
| 34 | + tar -xjf Fox-VERSION.tar.bz2 |
| 35 | +
|
| 36 | +Get the latest Fox from the git repository |
| 37 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 38 | + |
| 39 | +.. code-block:: shell |
| 40 | +
|
| 41 | + git clone https://github.com/vincefn/objcryst.git |
| 42 | + mv objcryst Fox |
| 43 | + cd Fox/ObjCryst |
| 44 | + ln -sf rules-gnu.mak rules.mak |
| 45 | + cd ../Fox |
| 46 | + ln -sf gnu.mak Makefile |
| 47 | +
|
| 48 | +Compile & install Fox |
| 49 | +--------------------- |
| 50 | + |
| 51 | +To compile and install Fox, go to the Fox/Fox subdirectory (or Fox-VERSION/Fox/), and then type: |
| 52 | + |
| 53 | +.. code-block:: shell |
| 54 | +
|
| 55 | + make shared=1 # See note below about shared libraries options |
| 56 | + sudo make install #(for this last step you must be root). |
| 57 | +
|
| 58 | +**Note 1**: there are several options for the ```make``` command: |
| 59 | + |
| 60 | +If fftw, wxgtk (>=3.0.2), freeglut or newmat are already available as shared libraries on your computer, |
| 61 | +you can use them without recompiling them. You can just append ```shared-wxgtk=1```, ```shared-glut=1```, |
| 62 | +``shared-fftw=1``` and ```shared-newmat=1```. |
| 63 | + |
| 64 | +If you have all five shared libraries (as possible for Debian and Ubuntu), just use ```shared=1```. Examples: |
| 65 | + |
| 66 | +.. code-block:: shell |
| 67 | +
|
| 68 | + make shared-wxgtk=1 shared-glut=1 shared-fftw=1 |
| 69 | +
|
| 70 | + make shared=1 |
| 71 | +
|
| 72 | +
|
| 73 | +Fox will be installed in /usr/local/bin/Fox. Otherwise the compiled file is in the `src/Fox` subdirectory. |
| 74 | + |
| 75 | +**Note 2**: if during the early stages of the compilation (when freeglut is compiled), you get |
| 76 | +an error message about ```libGL.la```, this can mean that ```libGL.la``` is not in the same |
| 77 | +directory as other x11 libraries. On my computer, where ```libGL.la``` is provided by the nVidia |
| 78 | +installer, I needed to do "```ln -s /usr/lib/libGL.la /usr/X11R6/lib/```". |
| 79 | + |
| 80 | +Compile & install Fox without GUI (Fox-nogui) |
| 81 | +--------------------------------------------- |
| 82 | + |
| 83 | +It is possible to compile a version of Fox that does not use a GUI and can only be used |
| 84 | +from the command-line. This is useful if you want to use Fox on a cluster. |
| 85 | +To do that just you just need to compile the ```Fox-nogui``` target: |
| 86 | + |
| 87 | +.. code-block:: shell |
| 88 | +
|
| 89 | + tar -xjf Fox-VERSION.tar.bz2 |
| 90 | + cd Fox-VERSION |
| 91 | + cd Fox |
| 92 | + make Fox-nogui shared=1 |
| 93 | +
|
| 94 | +The resulting application is ```src/Fox-nogui``` |
| 95 | + |
| 96 | +Note that when switching from building ```Fox``` to building ```Fox-nogui``` (and vice-versa) |
| 97 | +you must do a ``` make tidy``` first in the build directory. |
| 98 | + |
| 99 | +Compiling an optimized version of Fox |
| 100 | +------------------------------------- |
| 101 | +*Note: the instructions below are most likely obsolete as they were written > 15 years ago, they are |
| 102 | +left just in case they can be usefu. Feel free to experiment and propose an update !* |
| 103 | +Compile options |
| 104 | +^^^^^^^^^^^^^^^ |
| 105 | +The first set of optimizations can be activated by using processor-specific optimizations. |
| 106 | +If you edit the ```Fox/ObjCryst/rules.mak``` file, and search for the part where the ```CPPFLAGS``` are defined: |
| 107 | + |
| 108 | +.. code-block:: shell |
| 109 | +
|
| 110 | + CPPFLAGS = -O3 -w -ffast-math -fstrict-aliasing -pipe -fomit-frame-pointer -funroll-loops |
| 111 | +
|
| 112 | +*Auto-vectorization*: starting with gcc 4.0.0, it is possible to automatically **vectorize** some loops: |
| 113 | +append ```-ftree-vectorize``` to the ```CPPFLAGS``` options to do that |
| 114 | +(see the examples commented out in the ```rules.mak``` file). |
| 115 | + |
| 116 | +Profile driven optimizations |
| 117 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 118 | + |
| 119 | +Fox can be further optimized by making "test runs" which are used to give hints to the compiler |
| 120 | +on how to best optimize the code. To do this you (i) compile Fox by enabling the "recording" |
| 121 | +of the optimization, then (ii) you run a few optimizations, then (iii) you recompile using the |
| 122 | +recorded profile. To do that from the Fox subdirectory, do: |
| 123 | + |
| 124 | +.. code-block:: shell |
| 125 | +
|
| 126 | + make clean |
| 127 | + make Fox profile=2 |
| 128 | + src/Fox --nogui example/pbso4-joint.xml --randomize -n 50000 -o /dev/null |
| 129 | + src/Fox --nogui example/Cimetidine-powder.xml --randomize -n 50000 -o /dev/null |
| 130 | + src/Fox --speedtest |
| 131 | + make clean |
| 132 | + make Fox profile=3 |
| 133 | + make install |
| 134 | +
|
| 135 | +This yields about 10% faster code. |
| 136 | + |
| 137 | +If you also launch the Fox GUI and do a profile-fitting (between the 'profile=2' and 'profile=3' compilations), |
| 138 | +this will also **accelerate profile fitting and least squares operations**. |
0 commit comments