Logo AND Algorithmique Numérique Distribuée

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