Logo AND Algorithmique Numérique Distribuée

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