Logo AND Algorithmique Numérique Distribuée

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