Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ptask_BMF: High-level documentation of BMF and the algorithm
[simgrid.git] / docs / source / Installing_SimGrid.rst
1 .. Copyright 2005-2022
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 To get all of SimGrid on Debian or Ubuntu, simply type one of the
20 following lines, or several lines if you need several languages.
21
22 .. code-block:: console
23
24    $ apt install libsimgrid-dev  # if you want to develop in C or C++
25    $ apt install simgrid-java    # if you want to develop in Java
26    $ apt install python3-simgrid # if you want to develop in Python
27
28 If you use the Nix_ package manager, the latest SimGrid release is packaged as ``simgrid`` in Nixpkgs_.
29 Previous SimGrid versions are maintained in `NUR-Kapack`_ and are available
30 pre-compiled in release and debug modes on the `capack cachix binary cache`_
31 — refer to `NUR-Kapack's documentation`_ for usage instructions.
32
33 If you use a pacman-based system (*e.g.*, Arch Linux and derived distributions),
34 the latest SimGrid is available in the `simgrid AUR package`_
35 — refer to `AUR official documentation`_ for installation instructions.
36
37 If you build pre-compiled packages for other distributions, drop us an
38 email.
39
40 .. _Nix: https://nixos.org/
41 .. _Nixpkgs: https://github.com/NixOS/nixpkgs
42 .. _NUR-Kapack: https://github.com/oar-team/nur-kapack
43 .. _capack cachix binary cache: https://app.cachix.org/cache/capack
44 .. _NUR-Kapack's documentation: https://github.com/oar-team/nur-kapack
45 .. _simgrid AUR package: https://aur.archlinux.org/packages/simgrid/
46 .. _AUR official documentation: https://wiki.archlinux.org/title/Arch_User_Repository
47
48 .. _install_java_precompiled:
49
50 Stable Java Package
51 ^^^^^^^^^^^^^^^^^^^
52
53 The jar file can be retrieved from the `Release page
54 <https://framagit.org/simgrid/simgrid/-/releases>`_. This file is
55 self-contained, including the native components for Linux, macOS and
56 Windows. Copy it to your project's classpath and you're set.
57
58 Nightly built Java Package
59 ^^^^^^^^^^^^^^^^^^^^^^^^^^
60
61 Head to the corresponding `GitHub Action <https://github.com/simgrid/simgrid/actions/workflows/jarfile.yml>`_
62 and pick the last green build. At the bottom of the build page, click on the ``jar-final`` artefact.
63 Open this zip file to find the jar you need. This jar can be used under Linux, Mac OSX or Windows, as you wish.
64
65 Binary Java Troubleshooting
66 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
67
68 Here are some error messages that you may get when trying to use the
69 binary Java package.
70
71 Your architecture is not supported by this jarfile
72    If your system is not supported, you should compile your
73    own jarfile :ref:`by compiling SimGrid <install_src>` from the source.
74 Library not found: boost-context
75    You should obviously install the ``boost-context`` library on your
76    machine, for example with ``apt``.
77
78 .. _deprecation_policy:
79
80 Version numbering and deprecation
81 ---------------------------------
82
83 SimGrid tries to be both a research instrument that you can trust, and
84 a vivid project targeting the future issues. We have 4 stable versions
85 per year, numbered 3.24 or 3.25. Backward compatibility is ensured for
86 one year: Code compiling without warning on 3.24 will still compile
87 with 3.28, but maybe with some deprecation warnings. You should update
88 your SimGrid installation at least once a year and fix those
89 deprecation warnings: the compatibility wrappers are usually removed
90 after 4 versions. Another approach is to never update your SimGrid
91 installation, but we don't provide any support to old versions.
92
93 Interim versions (also called pre-versions) may be released between
94 stable releases. They are numbered 3.X.Y, with even Y (for example,
95 3.23.2 was released on July 8. 2019 as a pre-version of 3.24). These
96 versions should be as usable as regular stable releases, even if they
97 may be somewhat less tested and documented. They play no role in our
98 deprecation handling, and they are not really announced to not spam
99 our users.
100
101 Version numbered 3.X.Y with odd Y are git versions. They often work,
102 but no guarantee is given whatsoever (all releases are given "as is",
103 but that's even more so for these unreleased versions).
104
105 .. _install_src:
106
107 Installing from the Source
108 --------------------------
109
110 Getting the Dependencies
111 ^^^^^^^^^^^^^^^^^^^^^^^^
112
113 C++ compiler (either g++, clang, or icc).
114   We use the C++14 standard, and older compilers tend to fail on
115   us. It seems that g++ 5.0 or higher is required nowadays (because of
116   boost).  SimGrid compiles well with `clang` or `icc` too.
117 Python 3.
118   SimGrid should build without Python. That is only needed by our regression test suite.
119 cmake (v3.5).
120   ``ccmake`` provides a nicer graphical interface compared to ``cmake``.
121   Press ``t`` in ``ccmake`` if you need to see absolutely all
122   configuration options (e.g., if your Python installation is not standard).
123 boost (at least v1.48, v1.59 recommended)
124   - On Debian / Ubuntu: ``apt install libboost-dev libboost-context-dev``
125   - On macOS with homebrew: ``brew install boost``
126 Eigen3
127   - On Debian / Ubuntu: ``apt install libeigen3-dev``
128   - On macOS with homebrew: ``brew install eigen``
129 Java (optional):
130   - Debian / Ubuntu: ``apt install default-jdk libgcj18-dev`` (or
131     any version of libgcj)
132   - macOS or Windows: Grab a `full JDK <http://www.oracle.com/technetwork/java/javase/downloads>`_
133
134 For platform-specific details, please see below.
135
136 Getting the Sources
137 ^^^^^^^^^^^^^^^^^^^
138
139 Grab the last **stable release** from `FramaGit
140 <https://framagit.org/simgrid/simgrid/-/releases>`_, and compile it as follows:
141
142 .. code-block:: console
143
144    $ tar xf simgrid-3-XX.tar.gz
145    $ cd simgrid-*
146    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
147    $ make
148    $ make install
149
150 If you want to stay on the **bleeding edge**, get the current git version,
151 and recompile it as with stable archives. You may need some extra
152 dependencies.
153
154 .. code-block:: console
155
156    $ git clone https://framagit.org/simgrid/simgrid.git
157    $ cd simgrid
158    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
159    $ make
160    $ make install
161
162 .. _install_src_config:
163
164 Build Configuration
165 ^^^^^^^^^^^^^^^^^^^
166
167 This section is about **compile-time options**, which are very
168 different from :ref:`run-time options <options>`. Compile-time options
169 fall into two categories. **SimGrid-specific options** define which part
170 of the framework to compile while **Generic options** are provided by
171 cmake itself.
172
173 .. warning::
174
175    Our build system often gets mixed up if you change something on
176    your machine after the build configuration.  For example, if
177    SimGrid fails to detect your fortran compiler, it is not enough to
178    install a fortran compiler. You also need to delete all Cmake
179    files, such as ``CMakeCache.txt``. Since Cmake also generates some
180    files in the tree, you may need to wipe out your complete tree and
181    start with a fresh one when you install new dependencies.
182
183    Another (better) solution is to :ref:`build out of the source tree
184    <install_cmake_outsrc>`.
185
186 Generic build-time options
187 """"""""""""""""""""""""""
188
189 These options specify, for example, the path to various system elements (Python
190 path, compiler to use, etc). In most case, CMake automatically discovers the
191 right value for these elements, but you can set them manually as needed.
192 Notably, such variables include ``CC`` and ``CXX``, defining the paths to the C
193 and C++ compilers; ``CFLAGS`` and ``CXXFLAGS`` specifying extra options to pass
194 to the C and C++ compilers; and ``PYTHON_EXECUTABLE`` specifying the path to the
195 Python executable.
196
197 The best way to discover the exact name of the option that you need to
198 change is to press ``t`` in the ``ccmake`` graphical interface, as all
199 options are shown (and documented) in the advanced mode.
200
201 Once you know their name, there are several ways to change the values of
202 build-time options. You can naturally use the ccmake graphical
203 interface for that, or you can use environment variables, or you can
204 prefer the ``-D`` flag of ``cmake``.
205
206 For example, you can change the compilers by issuing these commands to set some
207 environment variables before launching cmake:
208
209 .. code-block:: console
210
211    $ export CC=gcc-5.1
212    $ export CXX=g++-5.1
213
214 The same can be done by passing ``-D`` parameters to cmake, as follows.
215 Note that the dot at the end is mandatory (see :ref:`install_cmake_outsrc`).
216
217 .. code-block:: console
218
219    $ cmake -DCC=clang -DCXX=clang++ .
220
221 SimGrid compilation options
222 """""""""""""""""""""""""""
223
224 Here is the list of all SimGrid-specific compile-time options (the
225 default choice is in upper case).
226
227 CMAKE_INSTALL_PREFIX (path)
228   Where to install SimGrid (/opt/simgrid, /usr/local, or elsewhere).
229
230 enable_compile_optimizations (ON/off)
231   Ask the compiler to produce efficient code. You probably want to
232   leave this option activated, unless you plan to modify SimGrid itself:
233   efficient code takes more time to compile, and appears mangled to some debuggers.
234
235 enable_compile_warnings (on/OFF)
236   Ask the compiler to issue error messages whenever the source
237   code is not perfectly clean. If you are a SimGrid developer, you
238   have to activate this option to enforce the code quality. As a
239   regular user, this option is of little use.
240
241 enable_debug (ON/off)
242   Disabling this option discards all log messages of severity
243   debug or below at compile time (see :ref:`outcome_logs`). The resulting
244   code is marginaly faster than if you discard these messages at
245   runtime, but it obviously becomes impossible to get any debug
246   info from SimGrid when things go wrong.
247
248 enable_documentation (on/OFF)
249   Generates the documentation pages. Building the documentation is not
250   as easy as it used to be, and you should probably use the online
251   version for now.
252
253 enable_java (on/OFF)
254   Generates the java bindings of SimGrid. You must also enable MSG for
255   this to work.
256
257 enable_lib_in_jar (ON/off)
258   Embeds the native java bindings into the produced jar file.
259
260 enable_lto (ON/off)
261   Enables the *Link Time Optimization* in the C++ compiler.
262   This feature really speeds up the code produced, but it is fragile
263   with older gcc versions.
264
265 enable_maintainer_mode (on/OFF)
266   (dev only) Regenerates the XML parsers whenever the DTD is modified (requires flex and flexml).
267
268 enable_mallocators (ON/off)
269   Activates our internal memory caching mechanism. This produces faster
270   code, but it may fool the debuggers.
271
272 enable_model-checking (on/OFF)
273   Activates the formal verification mode. This will **hinder
274   simulation speed** even when the model checker is not activated at
275   run time.
276
277 enable_msg (on/OFF)
278   Activates the :ref:`MSG <MSG_doc>` legacy interface.
279
280 enable_ns3 (on/OFF)
281   Activates the ns-3 bindings. See section :ref:`model_ns3`.
282
283 enable_smpi (ON/off)
284   Allows one to run MPI code on top of SimGrid.
285
286 enable_smpi_MBI_testsuite (on/OFF)
287   Adds many extra tests for the model checker module.
288
289 enable_smpi_MPICH3_testsuite (on/OFF)
290   Adds many extra tests for the MPI module.
291
292 minimal-bindings (on/OFF)
293   Take as few optional dependencies as possible, to get minimal
294   library bindings in Java and Python.
295
296 NS3_HINT (empty by default)
297   Alternative path into which ns-3 should be searched for.
298
299 SIMGRID_PYTHON_LIBDIR (auto-detected)
300   Where to install the Python module library. By default, it is set to the cmake Python3_SITEARCH variable if installing to /usr, 
301   and a modified version of that variable if installing to another path. Just force another value if the auto-detected default 
302   does not fit your setup.
303
304 SMPI_C_FLAGS, SMPI_CXX_FLAGS, SMPI_Fortran_FLAGS (string)
305   Default compiler options to use in smpicc, smpicxx, or smpiff.
306   This can be useful to set options like "-m32" or "-m64".
307
308 Reset the build configuration
309 """""""""""""""""""""""""""""
310
311 To empty the CMake cache (either when you add a new library or when
312 things go seriously wrong), simply delete your ``CMakeCache.txt``. You
313 may also want to directly edit this file in some circumstances.
314
315 .. _install_cmake_outsrc:
316
317 Out of Tree Compilation
318 ^^^^^^^^^^^^^^^^^^^^^^^
319
320 By default, the files produced during the compilation are placed in
321 the source directory. It is however often better to put them all in a
322 separate directory: cleaning the tree becomes as easy as removing this
323 directory, and you can have several such directories to test several
324 parameter sets or architectures.
325
326 For that, go to the directory where the files should be produced, and
327 invoke cmake (or ccmake) with the full path to the SimGrid source as
328 last argument.
329
330 .. code-block:: console
331
332   $ mkdir build
333   $ cd build
334   $ cmake [options] ..
335   $ make
336
337 Existing Compilation Targets
338 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
339
340 In most cases, compiling and installing SimGrid is enough:
341
342 .. code-block:: console
343
344   $ make
345   $ make install # try "sudo make install" if you don't have the permission to write
346
347 In addition, several compilation targets are provided in SimGrid. If
348 your system is well configured, the full list of targets is available
349 for completion when using the ``Tab`` key. Note that some of the
350 existing targets are not really for public consumption so don't worry
351 if some do not work for you.
352
353 - **make**: Build the core of SimGrid that gets installed, but not any example.
354 - **make tests**: Build the tests and examples.
355 - **make simgrid**: Build only the SimGrid library. Not any example nor the helper tools.
356 - **make s4u-comm-pingpong**: Build only this example (works for any example)
357 - **make java-all**: Build all Java examples and their dependencies
358 - **make clean**: Clean the results of a previous compilation
359 - **make install**: Install the project (doc/ bin/ lib/ include/)
360 - **make uninstall**: Uninstall the project (doc/ bin/ lib/ include/)
361 - **make dist**: Build a distribution archive (tar.gz)
362 - **make distcheck**: Check the dist (make + make dist + tests on the distribution)
363 - **make documentation**: Create SimGrid documentation
364
365 If you want to see what is really happening, try adding ``VERBOSE=1`` to
366 your compilation requests:
367
368 .. code-block:: console
369
370   $ make VERBOSE=1
371
372 .. _install_src_test:
373
374 Testing your build
375 ^^^^^^^^^^^^^^^^^^
376
377 Once everything is built, you may want to test the result. SimGrid
378 comes with an extensive set of regression tests (as described in the
379 @ref inside_tests "insider manual"). The tests are not built by
380 default, so you first have to build them with ``make tests``. You can
381 then run them with ``ctest``, that comes with CMake.  We run them
382 every commit and the results are on `our Jenkins <https://ci.inria.fr/simgrid/>`_.
383
384 .. code-block:: console
385
386   $ make tests                # Build the tests
387   $ ctest                     # Launch all tests
388   $ ctest -R s4u              # Launch only the tests whose names match the string "s4u"
389   $ ctest -j4                 # Launch all tests in parallel, at most 4 concurrent jobs
390   $ ctest --verbose           # Display all details on what's going on
391   $ ctest --output-on-failure # Only get verbose for the tests that fail
392
393   $ ctest -R s4u -j4 --output-on-failure # You changed S4U and want to check that you  \
394                                          # didn't break anything, huh?                 \
395                                          # That's fine, I do so all the time myself.
396
397 .. _install_cmake_mac:
398
399 macOS-specific instructions
400 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
401
402 SimGrid compiles like a charm with clang (version 3.0 or higher) on macOS:
403
404 .. code-block:: console
405
406   $ cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
407   $ make
408
409
410 Troubleshooting your macOS build.
411
412 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
413   This was reported with the XCode version of clang 4.1. The work
414   around is to edit the ``CMakeCache.txt`` file directly, to change
415   the following entry:
416
417   ``CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer``
418
419   You can safely ignore the warning about "-pthread" not being used, if it appears.
420
421 /usr/include does not seem to exist
422   This directory does not exist by default on modern macOS versions,
423   and you may need to create it with ``xcode-select -install``
424
425 .. _install_cmake_windows:
426
427 Windows-specific instructions
428 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
429
430 The best solution to get SimGrid working on windows is to install the
431 Ubuntu subsystem of Windows 10. All of SimGrid (but the model checker)
432 works in this setting.
433
434 Native builds not very well supported. Have a look to our `appveypor
435 configuration file
436 <https://framagit.org/simgrid/simgrid/blob/master/.appveyor.yml>`_ to
437 see how we manage to use mingw-64 to build the DLL that the Java file
438 needs.
439
440 The drawback of MinGW-64 is that the produced DLL are not compatible
441 with MS Visual C. Some clang-based tools seem promising to fix this,
442 but this is of rather low priority for us. It it's important for you
443 and if you get it working, please @ref community_contact "tell us".
444
445 Python-specific instructions
446 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
447
448 Once you have the Python development headers installed as well as a
449 recent version of the `pybind11 <https://pybind11.readthedocs.io/en/stable/>`
450 module (version at least 2.4), recompiling the Python bindings from
451 the source should be as easy as:
452
453 .. code-block:: console
454
455   # cd simgrid-source-tree
456   $ python setup.py build install
457
458 Starting with SimGrid 3.13, it should even be possible to install
459 simgrid without downloading the source with pip:
460
461 .. code-block:: console
462
463   $ pip install simgrid
464
465 Java-specific instructions
466 ^^^^^^^^^^^^^^^^^^^^^^^^^^
467
468 Once you have the `full JDK <http://www.oracle.com/technetwork/java/javase/downloads>`_ installed,
469 things should be as simple as:
470
471 .. code-block:: console
472
473    $ cmake -Denable_java=ON -Dminimal-bindings=ON .
474    $ make  simgrid-java_jar # Only build the jarfile
475
476 After the compilation, the file ```simgrid.jar``` is produced in the
477 root directory.
478
479 **Troubleshooting Java Builds**
480
481 Sometimes, the build system fails to find the JNI headers. First locate them as follows:
482
483 .. code-block:: console
484
485   $ locate jni.h
486   /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h
487   /usr/lib/jvm/java-9-openjdk-amd64/include/jni.h
488   /usr/lib/jvm/java-10-openjdk-amd64/include/jni.h
489
490
491 Then, set the JAVA_INCLUDE_PATH environment variable to the right
492 path, and relaunch cmake. If you have several versions of JNI installed
493 (as above), pick the one corresponding to the report of
494 ``javac -version``
495
496 .. code-block:: console
497
498   $ export JAVA_INCLUDE_PATH=/usr/lib/jvm/java-8-openjdk-amd64/include/
499   $ cmake -Denable_java=ON .
500   $ make
501
502 Note that the filename ```jni.h``` was removed from the path.
503
504 Linux Multi-Arch specific instructions
505 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
506
507 On a multiarch x86_64 Linux, it should be possible to compile a 32-bit
508 version of SimGrid with something like:
509
510 .. code-block:: console
511
512   $ CFLAGS=-m32                                                      \
513     CXXFLAGS=-m32                                                    \
514     FFLAGS=-m32                                                      \
515     PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig/             \
516     cmake .                                                          \
517       -DCMAKE_SYSTEM_PROCESSOR=i386                                  \
518       -DCMAKE_Fortran_COMPILER=/some/path/to/i686-linux-gnu-gfortran \
519       -DGFORTRAN_EXE=/some/path/to/i686-linux-gnu-gfortran           \
520       -DSMPI_C_FLAGS=-m32                                            \
521       -DSMPI_CXX_FLAGS=-m32                                          \
522       -DSMPI_Fortran_FLAGS=-m32
523
524 If needed, implement ``i686-linux-gnu-gfortran`` as a script:
525
526 .. code-block:: shell
527
528   #!/usr/bin/env sh
529   exec gfortran -m32 "$@"