Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / docs / source / installation.rst
1 .. Copyright 2005-2018 
2
3 .. _install:
4
5 Installing SimGrid
6 ==================
7
8    
9 SimGrid should work out of the box on Linux, Mac OSX, FreeBSD, and Windows (under windows, only the Java interfaces are
10 available at the moment).
11
12 Pre-compiled Packages
13 ---------------------
14
15 Binaries for Linux
16 ^^^^^^^^^^^^^^^^^^
17
18 On Debian or Ubuntu, simply type:
19
20 .. code-block:: shell
21    
22    apt install simgrid
23
24 If you build pre-compiled packages for other distributions, drop us an
25 email.
26    
27 Stable Java Package
28 ^^^^^^^^^^^^^^^^^^^
29
30 The jar file can be retrieved from the `Release page
31 <https://framagit.org/simgrid/simgrid/tags>`_. This file is
32 self-contained, including the native components for Linux, Mac OSX and
33 Windows. Copy it to your project's classpath and you're set.
34
35 Nightly built Java Package
36 ^^^^^^^^^^^^^^^^^^^^^^^^^^
37
38 For non-Windows systems (Linux, Mac or FreeBSD), head to `Jenkins <https://ci.inria.fr/simgrid/job/SimGrid>`_.
39 In the build history, pick the last green (or at least yellow) build that is not blinking (i.e., not currently under 
40 build). In the list, pick a system that is close to yours, and click on the ball in the Debug row. The build artefact 
41 will appear on the top of the resulting page.
42
43 For Windows, head to `AppVeyor <https://ci.appveyor.com/project/simgrid/simgrid>`_.
44 Click on the artefact link on the right, and grab your file. If the latest build failed, there will be no artefact. Then
45 you will need to first click on "History" on the top and search for the last successful build.
46
47 Binary Java Troubleshooting
48 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
49
50 Here are some error messages that you may get when trying to use the
51 binary Java package.
52
53 Your architecture is not supported by this jarfile
54    If your system is not supported, you should compile your
55    own jarfile :ref:`by compiling SimGrid <install_src>` from the source.
56 Library not found: boost-context
57    You should obviously install the ``boost-context`` library on your
58    machine, for example with ``apt``.
59
60 .. _install_src:
61    
62 Installing from the Source
63 --------------------------
64
65 Getting the Dependencies
66 ^^^^^^^^^^^^^^^^^^^^^^^^
67
68 C++ compiler (either g++, clang or icc).
69   We use the C++11 standard, and older compilers tend to fail on
70   us. It seems that g++ 5.0 or higher is required nowadays (because of
71   boost).  SimGrid compiles well with `clang` or `icc` too.
72 Python 3.
73   SimGrid should build without Python, that is only needed by our regresion test suite.
74 cmake (v2.8.8).
75   ``ccmake`` provides a nicer graphical interface compared to ``cmake``.
76   Press ``t`` in ``ccmake`` if you need to see absolutely all
77   configuration options (e.g., if your python installation is not standard).
78 boost (at least v1.48, v1.59 recommended)
79   - On Debian / Ubuntu: ``apt install libboost-dev libboost-context-dev``
80   - On Max OS X with homebrew: ``brew install boost``  
81 Java (optional):
82   - Debian / Ubuntu: ``apt install default-jdk libgcj18-dev`` (or
83     any version of libgcj)      
84   - Mac OS X or Windows: Grab a `full JDK <http://www.oracle.com/technetwork/java/javase/downloads>`_
85 Lua (optional -- must be v5.3)
86   - SimGrid won't work with any other version of Lua.
87   - Debian / Ubuntu: ``apt install liblua5.3-dev lua5.3``
88   - Windows: ``choco install lua53``
89   - From the source
90       - You need to patch the sources to build dynamic libraries. First `download lua 5.3 <http://www.lua.org/download.html>`_
91       - Open the archive: ``tar xvfz lua-5.3.*.tar.gz``
92       - Enter the directory: ``cd lua-5.3*``
93       - Patch the sources: ``patch -p1 < /path/to/simgrid/...../tools/lualib.patch``
94       - Build and install lua: ``make linux && sudo make install``
95
96 For platform-specific details, please see below.
97
98 Getting the Sources
99 ^^^^^^^^^^^^^^^^^^^
100
101 Grab the last **stable release** from `FramaGit
102 <https://framagit.org/simgrid/simgrid/tags>`_, and compile it as follows:
103
104 .. code-block:: shell
105
106    tar xf SimGrid-3-XX.tar.gz
107    cd SimGrid-*
108    cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
109    make
110    make install
111
112 If you want to stay on the **bleeding edge**, get the current git version,
113 and recompile it as with stable archives. You may need some extra
114 dependencies.
115
116 .. code-block:: shell
117  
118    git clone git@framagit.org:simgrid/simgrid.git
119    cd simgrid
120    cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
121    make
122    make install
123
124 Build Configuration
125 ^^^^^^^^^^^^^^^^^^^
126
127 This section is about **compile-time options**, that are very
128 different from @ref options "run-time options". Compile-time options
129 fall into two categories. *SimGrid-specific options* define which part
130 of the framework to compile while *Generic options* are provided by
131 cmake itself.
132
133 Generic build-time options
134 """"""""""""""""""""""""""
135
136 These options specify for example the path to various system elements
137 (Python path, compiler to use, etc). In most case, cmake automatically
138 discovers the right value for these ones, but you can set them
139 manually on need.  Notable such variables include ``CC`` and ``CXX``,
140 defining respectively the paths to the C and C++ compilers, ``CFLAGS``
141 and ``CXXFLAGS`` respectively specifying extra options to pass to the C
142 and C++ compilers, or ``PYTHON_EXECUTABLE`` specifying the path to the
143 python executable.
144
145 The best way to discover the exact name of the option that you need to
146 change is to press ``t`` in the ``ccmake`` graphical interface, as all
147 options are shown (and documented) in the advanced mode.
148
149 Once you know their name, there is several ways to change the value of
150 build-time options. You can naturally use the ccmake graphical
151 interface for that, or you can use environment variables, or you can
152 prefer the ``-D`` flag of ``cmake``.
153
154 For example, you can change the compilers with environment variables
155 by issuing these commands before launching cmake:
156
157 .. code-block:: shell
158  
159    export CC=gcc-5.1
160    export CXX=g++-5.1
161
162 The same can be done by passing ``-D`` parameters to cmake, as follows.
163 Note that the ending dot is mandatory (see :ref:`install_cmake_outsrc`).
164
165 .. code-block:: shell
166
167    cmake -DCC=clang -DCXX=clang++ .
168
169 SimGrid compilation options
170 """""""""""""""""""""""""""
171
172 Here is the list of all SimGrid-specific build-time options (the
173 default choice is in uppercase).
174
175 CMAKE_INSTALL_PREFIX (path)
176   Where to install SimGrid (/opt/simgrid, /usr/local, or elsewhere).
177   
178 enable_compile_optimizations (ON/off)
179   Request the compiler to produce efficient code. You probably want to
180   activate this option, unless you plan modify SimGrid itself: 
181   efficient code takes more time to compile, and appears mangled to debuggers.
182
183 enable_compile_warnings (on/OFF)
184   Request the compiler to issue error messages whenever the source
185   code is not perfectly clean. If you are a SimGrid developer, you
186   have to activate this option to enforce the code quality. As a
187   regular user, this option is of little use.
188
189 enable_debug (ON/off)
190   Disabling this option toto discards all log messages of gravity
191   debug or below at compile time (see @ref XBT_log). The resulting
192   code is faster than if you discarding these messages at
193   runtime. However, it obviously becomes impossible to get any debug
194   info from SimGrid if something goes wrong.
195
196 enable_documentation (ON/off)
197   Generates the documentation pages.
198
199 enable_java (on/OFF)
200   Generates the java bindings of SimGrid.
201
202 enable_jedule (on/OFF)
203   Produces execution traces from SimDag simulations, that can then be visualized with the 
204   Jedule external tool.
205
206 enable_lua (on/OFF)
207   Generate the lua bindings to the SimGrid internals (requires lua-5.3).
208
209 enable_lib_in_jar (ON/off)
210   Embeds the native java bindings into the produced jar file.
211
212 enable_lto (ON/off)
213   Enables the *Link Time Optimization* in the C++ compiler.
214   This feature really speeds up the produced code, but it is fragile
215   with older gcc versions.
216
217 enable_maintainer_mode (on/OFF)
218   (dev only) Regenerates the XML parsers when the dtd is modified (requires flex and flexml).
219
220 enable_mallocators (ON/off)
221   Activates our internal memory caching mechanism. This produces faster
222   code, but it may fool the debuggers. 
223
224 enable_model-checking (on/OFF)
225   Activates the formal verification mode. This will **hinder
226   simulation speed** even when the model-checker is not activated at
227   run time.
228
229 enable_ns3 (on/OFF)
230   Activates the ns-3 bindings. See section @ref pls_ns3.
231
232 enable_smpi (ON/off)
233   Allows to run MPI code on top of SimGrid.
234
235 enable_smpi_ISP_testsuite (on/OFF)
236   Adds many extra tests for the model-checker module.
237
238 enable_smpi_MPICH3_testsuite (on/OFF)
239   Adds many extra tests for the MPI module.
240
241 Reset the build configuration
242 """""""""""""""""""""""""""""
243
244 To empty the cmake cache (either when you add a new library or when
245 things go seriously wrong), simply delete your ``CMakeCache.txt``. You
246 may also want to directly edit this file in some circumstances.
247
248 .. _install_cmake_outsrc:
249
250 Out of Tree Compilation
251 ^^^^^^^^^^^^^^^^^^^^^^^
252
253 By default, the files produced during the compilation are placed in
254 the source directory. It is however often better to put them all in a
255 separate directory: cleaning the tree becomes as easy as removing this
256 directory, and you can have several such directories to test several
257 parameter sets or architectures.
258
259 For that, go to the directory where the files should be produced, and
260 invoke cmake (or ccmake) with the full path to the SimGrid source as
261 last argument.
262
263 .. code-block:: shell
264
265   mkdir build
266   cd build
267   cmake [options] ..
268   make
269
270 Existing Compilation Targets
271 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
272
273 In most cases, compiling and installing SimGrid is enough:
274
275 .. code-block:: shell
276
277   make
278   make install # try "sudo make install" if you don't have the permission to write
279
280 In addition, several compilation targets are provided in SimGrid. If
281 your system is well configured, the full list of targets is available
282 for completion when using the ``Tab`` key. Note that some of the
283 existing targets are not really for public consumption so don't worry
284 if some stuff doesn't work for you.
285
286 make simgrid
287   Build only the SimGrid library and not any example
288 make s4u-app-pingpong
289   Build only this example (works for any example)
290 make clean
291   Clean the results of a previous compilation
292 make install
293   Install the project (doc/ bin/ lib/ include/)
294 make uninstall
295   Uninstall the project (doc/ bin/ lib/ include/)
296 make dist
297   Build a distribution archive (tar.gz)
298 make distcheck
299   Check the dist (make + make dist + tests on the distribution)
300 make documentation
301   Create SimGrid documentation
302
303 If you want to see what is really happening, try adding ``VERBOSE=1`` to
304 your compilation requests:
305
306 .. code-block:: shell
307
308   make VERBOSE=1
309
310 .. _install_src_test:
311
312 Testing your build
313 ^^^^^^^^^^^^^^^^^^
314
315 Once everything is built, you may want to test the result. SimGrid
316 comes with an extensive set of regression tests (as described in the
317 @ref inside_tests "insider manual"). The tests are run with ``ctest``,
318 that comes with CMake.  We run them every commit and the results are
319 on `our Jenkins <https://ci.inria.fr/simgrid/>`_.
320
321 .. code-block:: shell
322
323   ctest                     # Launch all tests
324   ctest -R s4u              # Launch only the tests which name match the string "s4u"
325   ctest -j4                 # Launch all tests in parallel, at most 4 concurrent jobs
326   ctest --verbose           # Display all details on what's going on
327   ctest --output-on-failure # Only get verbose for the tests that fail
328   
329   ctest -R s4u -j4 --output-on-failure # You changed S4U and want to check that you didn't break anything, huh?
330                                        # That's fine, I do so all the time myself.
331
332 .. _install_cmake_mac:
333
334 Mac OS X Specifics
335 ^^^^^^^^^^^^^^^^^^
336
337 SimGrid compiles like a charm with clang (version 3.0 or higher) on Mac OS X:
338
339 .. code-block:: shell
340                 
341   cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
342   make
343
344
345 Troubleshooting your Mac OS X build.
346   
347 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
348   This was reported with the XCode version of clang 4.1. The work
349   around is to edit the ``CMakeCache.txt`` file directly, to change
350   the following entry:
351                 
352   ``CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer``
353
354   You can safely ignore the warning about "-pthread" not being used, if it appears.
355   
356 /usr/include does not seem to exist
357   This directory does not exist by default on modern Mac OSX versions,
358   and you may need to create it with ``xcode-select -install``
359
360 .. _install_cmake_windows:
361
362 Windows Specifics
363 ^^^^^^^^^^^^^^^^^
364
365 The best solution to get SimGrid working on windows is to install the
366 Ubuntu subsystem of Windows 10. All of SimGrid (but the model-checker)
367 works in this setting.
368
369 Native builds not very well supported. Have a look to our `appveypor
370 configuration file
371 <https://framagit.org/simgrid/simgrid/blob/master/.appveyor.yml>`_ to
372 see how we manage to use mingw-64 to build the DLL that the Java file
373 needs.
374
375 The drawback of MinGW-64 is that the produced DLL are not compatible
376 with MS Visual C. `clang-cl <http://clang.llvm.org/docs/MSVCCompatibility.html">`_
377 sounds promising to fix this. If you get something working or if you
378 have any other improvement, please @ref community_contact "tell us".
379
380 Java Specifics
381 ^^^^^^^^^^^^^^
382
383 Once you have the `full JDK <http://www.oracle.com/technetwork/java/javase/downloads>`_ installed,
384 things should be as simple as:
385
386 .. code-block:: shell
387
388    cmake -Denable_java=ON .
389    make  simgrid-java_jar # Only build the jarfile
390
391 After the compilation, the file ```simgrid.jar``` is produced in the
392 root directory. 
393
394 **Troubleshooting Java Builds**
395
396 Sometimes, the build system fails to find the JNI headers. First locate them as follows:
397
398 .. code-block:: shell
399
400   $ locate jni.h
401   /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h
402   /usr/lib/jvm/java-9-openjdk-amd64/include/jni.h
403   /usr/lib/jvm/java-10-openjdk-amd64/include/jni.h
404
405
406 Then, set the JAVA_INCLUDE_PATH environment variable to the right
407 path, and relaunch cmake. If you have several version of jni installed
408 (as above), pick the one corresponding to the report of
409 ``javac -version`` 
410
411 .. code-block:: shell
412
413   export JAVA_INCLUDE_PATH=/usr/lib/jvm/java-8-openjdk-amd64/include/
414   cmake -Denable_java=ON .
415   make
416
417 Note that the filename ```jni.h``` was removed from the path.
418
419 Linux Multi-Arch Specifics
420 ^^^^^^^^^^^^^^^^^^^^^^^^^^
421
422 On a multiarch x86_64 Linux, it should be possible to compile a 32 bit
423 version of SimGrid with something like:
424
425 .. code-block:: shell
426
427   CFLAGS=-m32 \
428   CXXFLAGS=-m32 \
429   PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig/ \
430   cmake . \
431   -DCMAKE_SYSTEM_PROCESSOR=i386 \
432   -DCMAKE_Fortran_COMPILER=/some/path/to/i686-linux-gnu-gfortran \
433   -DGFORTRAN_EXE=/some/path/to/i686-linux-gnu-gfortran \
434   -DCMAKE_Fortran_FLAGS=-m32
435
436 If needed, implement ``i686-linux-gnu-gfortran`` as a script:
437
438 .. code-block:: shell
439                 
440   #!/usr/bin/env sh
441   exec gfortran -m32 "$@"
442