Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Troubleshooting Homebrew binaries on macOS (Thanks Paul Adam)
[simgrid.git] / docs / source / Installing_SimGrid.rst
1 .. Copyright 2005-2023
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 (with WSL).
11
12 Pre-compiled Packages
13 ---------------------
14
15 Binaries for Linux
16 ^^^^^^^^^^^^^^^^^^
17
18 To get all of SimGrid on Debian or Ubuntu, simply type one of the
19 following lines, or several lines if you need several languages.
20
21 .. code-block:: console
22
23    $ apt install libsimgrid-dev  # if you want to develop in C or C++
24    $ apt install python3-simgrid # if you want to develop in Python
25
26 If you use the Nix_ package manager, the latest SimGrid release is packaged as ``simgrid`` in Nixpkgs_.
27 Previous SimGrid versions are maintained in `NUR-Kapack`_ and are available
28 pre-compiled in release and debug modes on the `capack cachix binary cache`_
29 — refer to `NUR-Kapack's documentation`_ for usage instructions.
30
31 If you use a pacman-based system (*e.g.*, Arch Linux and derived distributions),
32 the latest SimGrid is available in the `simgrid AUR package`_
33 — refer to `AUR official documentation`_ for installation instructions.
34
35 If you build pre-compiled packages for other distributions, drop us an
36 email.
37
38 .. _Nix: https://nixos.org/
39 .. _Nixpkgs: https://github.com/NixOS/nixpkgs
40 .. _NUR-Kapack: https://github.com/oar-team/nur-kapack
41 .. _capack cachix binary cache: https://app.cachix.org/cache/capack
42 .. _NUR-Kapack's documentation: https://github.com/oar-team/nur-kapack
43 .. _simgrid AUR package: https://aur.archlinux.org/packages/simgrid/
44 .. _AUR official documentation: https://wiki.archlinux.org/title/Arch_User_Repository
45
46 Binaries from macOS
47 ^^^^^^^^^^^^^^^^^^^
48
49 SimGrid can be found in the Homebrew package manager. Troubleshooting:
50
51 warning: dylib (libsimgrid.dylib) was built for newer macOS version (14.0) than being linked (13.3)
52   This was reported with the SimGrid version from Homebrew on a Mac book air M1 (ARM).
53   The solution is simply to export this variable before the compilation of your binaries:
54
55   ``export MACOSX_DEPLOYMENT_TARGET=14.0``
56
57 .. _deprecation_policy:
58
59 Version numbering and deprecation
60 ---------------------------------
61
62 SimGrid tries to be both a research instrument that you can trust, and
63 a vivid project targeting the future issues. We have 4 stable versions
64 per year, numbered 3.24 or 3.25. Backward compatibility is ensured for
65 one year: Code compiling without warning on 3.24 will still compile
66 with 3.28, but maybe with some deprecation warnings. You should update
67 your SimGrid installation at least once a year and fix those
68 deprecation warnings: the compatibility wrappers are usually removed
69 after 4 versions. Another approach is to never update your SimGrid
70 installation, but we don't provide any support to old versions.
71
72 Interim versions (also called pre-versions) may be released between
73 stable releases. They are numbered 3.X.Y, with even Y (for example,
74 3.23.2 was released on July 8. 2019 as a pre-version of 3.24). These
75 versions should be as usable as regular stable releases, even if they
76 may be somewhat less tested and documented. They play no role in our
77 deprecation handling, and they are not really announced to not spam
78 our users.
79
80 Version numbered 3.X.Y with odd Y are git versions. They often work,
81 but no guarantee is given whatsoever (all releases are given "as is",
82 but that's even more so for these unreleased versions).
83
84 .. _install_src:
85
86 Installing from the Source
87 --------------------------
88
89 .. _install_src_deps:
90
91 Getting the Dependencies
92 ^^^^^^^^^^^^^^^^^^^^^^^^
93
94 C++ compiler (either g++, clang, or icc).
95   We use the C++17 standard, and older compilers tend to fail on
96   us. It seems that g++ 7.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 mandatory components (at least v1.48, v1.59 recommended)
105   - On Debian / Ubuntu: ``apt install libboost-dev``
106   - On CentOS / Fedora: ``dnf install boost-devel``
107   - On macOS with homebrew: ``brew install boost``
108 boost recommended components (optional).
109   - boost-context may be used instead of our own fast context switching code which only works on amd64.
110   - boost-stacktrace is used to get nice stacktraces on errors in SimGrid.
111   - On Debian / Ubuntu: ``apt install libboost-context-dev libboost-stacktrace-dev``
112 python bindings (optional):
113   - On Debian / Ubuntu: ``apt install pybind11-dev python3-dev``
114 Model-checking mandatory dependencies
115   - On Debian / Ubuntu: ``apt install libevent-dev``
116 Eigen3 (optional)
117   - On Debian / Ubuntu: ``apt install libeigen3-dev``
118   - On CentOS / Fedora: ``dnf install eigen3-devel``
119   - On macOS with homebrew: ``brew install eigen``
120   - Use EIGEN3_HINT to specify where it's installed if cmake doesn't find it automatically. Set EIGEN3_HINT=OFF to disable detection even if it could be found.
121 JSON (optional, for the DAG wfcommons loader)
122   - On Debian / Ubuntu: ``apt install nlohmann-json3-dev``
123   - Use nlohmann_json_HINT to specify where it's installed if cmake doesn't find it automatically.
124
125 For platform-specific details, please see below.
126
127 Getting the Sources
128 ^^^^^^^^^^^^^^^^^^^
129
130 Grab the last **stable release** from `FramaGit
131 <https://framagit.org/simgrid/simgrid/-/releases>`_, and compile it as follows:
132
133 .. code-block:: console
134
135    $ tar xf simgrid-3-XX.tar.gz
136    $ cd simgrid-*
137    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid -GNinja .
138    $ make
139    $ make install
140
141 If you want to stay on the **bleeding edge**, get the current git version,
142 and recompile it as with stable archives. You may need some extra
143 dependencies.
144
145 .. code-block:: console
146
147    $ git clone https://framagit.org/simgrid/simgrid.git
148    $ cd simgrid
149    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
150    $ make
151    $ make install
152
153 .. _install_src_config:
154
155 Build Configuration
156 ^^^^^^^^^^^^^^^^^^^
157
158 This section is about **compile-time options**, which are very
159 different from :ref:`run-time options <options>`. Compile-time options
160 fall into two categories. **SimGrid-specific options** define which part
161 of the framework to compile while **Generic options** are provided by
162 cmake itself.
163
164 .. warning::
165
166    Our build system often gets mixed up if you change something on
167    your machine after the build configuration.  For example, if
168    SimGrid fails to detect your fortran compiler, it is not enough to
169    install a fortran compiler. You also need to delete all Cmake
170    files, such as ``CMakeCache.txt``. Since Cmake also generates some
171    files in the tree, you may need to wipe out your complete tree and
172    start with a fresh one when you install new dependencies.
173
174    A better solution is to :ref:`build out of the source tree <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 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=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_lto (ON/off)
244   Enables the *Link Time Optimization* in the C++ compiler.
245   This feature really speeds up the code produced, but it is fragile
246   with older gcc versions.
247
248 enable_maintainer_mode (on/OFF)
249   (dev only) Regenerates the XML parsers whenever the DTD is modified (requires flex and flexml).
250
251 enable_mallocators (ON/off)
252   Activates our internal memory caching mechanism. This produces faster
253   code, but it may fool the debuggers.
254
255 enable_model-checking (ON/off)
256   Activates the verification mode. This should not impact the performance of your simulations if you build it but don't use it,
257   but you can still disable it to save some compilation time.
258
259 enable_ns3 (on/OFF)
260   Activates the ns-3 bindings. See section :ref:`models_ns3`.
261
262 enable_smpi (ON/off)
263   Allows one to run MPI code on top of SimGrid.
264
265 enable_testsuite_McMini (on/OFF)
266   Adds several extra tests for the model checker module (targeting threaded applications).
267
268 enable_testsuite_smpi_MBI (on/OFF)
269   Adds many extra tests for the model checker module (targeting MPI applications).
270
271 enable_testsuite_smpi_MPICH3 (on/OFF)
272   Adds many extra tests for the MPI module.
273
274 minimal-bindings (on/OFF)
275   Take as few optional dependencies as possible, to get minimal
276   library bindings in Python.
277
278 NS3_HINT (empty by default)
279   Alternative path into which ns-3 should be searched for.
280
281 EIGEN3_HINT (empty by default)
282   Alternative path into which Eigen3 should be searched for.
283   Providing the value OFF as an hint will disable the detection alltogether.
284
285 SIMGRID_PYTHON_LIBDIR (auto-detected)
286   Where to install the Python module library. By default, it is set to the cmake Python3_SITEARCH variable if installing to /usr,
287   and a modified version of that variable if installing to another path. Just force another value if the auto-detected default
288   does not fit your setup.
289
290 SMPI_C_FLAGS, SMPI_CXX_FLAGS, SMPI_Fortran_FLAGS (string)
291   Default compiler options to use in smpicc, smpicxx, or smpiff.
292   This can be useful to set options like "-m32" or "-m64".
293
294 Reset the build configuration
295 """""""""""""""""""""""""""""
296
297 To empty the CMake cache (either when you add a new library or when
298 things go seriously wrong), simply delete your ``CMakeCache.txt``. You
299 may also want to directly edit this file in some circumstances.
300
301 .. _install_cmake_outsrc:
302
303 Out of Tree Compilation
304 ^^^^^^^^^^^^^^^^^^^^^^^
305
306 By default, the files produced during the compilation are placed in
307 the source directory. It is however often better to put them all in a
308 separate directory: cleaning the tree becomes as easy as removing this
309 directory, and you can have several such directories to test several
310 parameter sets or architectures.
311
312 For that, go to the directory where the files should be produced, and
313 invoke cmake (or ccmake) with the full path to the SimGrid source as
314 last argument.
315
316 .. code-block:: console
317
318   $ mkdir build
319   $ cd build
320   $ cmake [options] ..
321   $ make
322
323 Existing Compilation Targets
324 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
325
326 In most cases, compiling and installing SimGrid is enough:
327
328 .. code-block:: console
329
330   $ make
331   $ make install # try "sudo make install" if you don't have the permission to write
332
333 In addition, several compilation targets are provided in SimGrid. If
334 your system is well configured, the full list of targets is available
335 for completion when using the ``Tab`` key. Note that some of the
336 existing targets are not really for public consumption so don't worry
337 if some do not work for you.
338
339 - **make**: Build the core of SimGrid that gets installed, but not any example.
340 - **make examples**: Build the examples, which are needed by the tests.
341 - **make simgrid**: Build only the SimGrid library. Not any example nor the helper tools.
342 - **make s4u-comm-pingpong**: Build only this example (works for any example)
343 - **make python-bindings**: Build the Python bindings
344 - **make clean**: Clean the results of a previous compilation
345 - **make install**: Install the project (doc/ bin/ lib/ include/)
346 - **make dist**: Build a distribution archive (tar.gz)
347 - **make distcheck**: Check the dist (make + make dist + tests on the distribution)
348 - **make documentation**: Create SimGrid documentation
349
350 If you want to see what is really happening, try adding ``VERBOSE=1`` to
351 your compilation requests:
352
353 .. code-block:: console
354
355   $ make VERBOSE=1
356
357 .. _install_src_test:
358
359 Testing your build
360 ^^^^^^^^^^^^^^^^^^
361
362 Once everything is built, you may want to test the result. SimGrid
363 comes with an extensive set of regression tests (as described in the
364 @ref inside_tests "insider manual"). The tests are not built by
365 default, so you first have to build them with ``make tests``. You can
366 then run them with ``ctest``, that comes with CMake.  We run them
367 every commit and the results are on `our Jenkins <https://ci.inria.fr/simgrid/>`_.
368
369 .. code-block:: console
370
371   $ make tests                # Build the tests
372   $ ctest                     # Launch all tests
373   $ ctest -R s4u              # Launch only the tests whose names match the string "s4u"
374   $ ctest -j4                 # Launch all tests in parallel, at most 4 concurrent jobs
375   $ ctest --verbose           # Display all details on what's going on
376   $ ctest --output-on-failure # Only get verbose for the tests that fail
377
378   $ ctest -R s4u -j4 --output-on-failure # You changed S4U and want to check that you  \
379                                          # didn't break anything, huh?                 \
380                                          # That's fine, I do so all the time myself.
381
382 .. _install_cmake_mac:
383
384 macOS-specific instructions
385 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
386
387 SimGrid compiles like a charm with clang (version 3.0 or higher) on macOS:
388
389 .. code-block:: console
390
391   $ cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
392   $ make
393
394
395 Troubleshooting your macOS build.
396
397 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
398   This was reported with the XCode version of clang 4.1. The work
399   around is to edit the ``CMakeCache.txt`` file directly, to change
400   the following entry:
401
402   ``CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer``
403
404   You can safely ignore the warning about "-pthread" not being used, if it appears.
405
406 /usr/include does not seem to exist
407   This directory does not exist by default on modern macOS versions,
408   and you may need to create it with ``xcode-select -install``
409
410 .. _install_cmake_windows:
411
412 Windows-specific instructions
413 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
414
415 The best solution to get SimGrid working on windows is to install the
416 Ubuntu subsystem of Windows 10. All of SimGrid 
417 works in this setting. Native builds never really worked, and they are
418 disabled starting with SimGrid v3.33.
419
420 Python-specific instructions
421 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
422
423 Once you have the Python development headers installed as well as a
424 recent version of the `pybind11 <https://pybind11.readthedocs.io/en/stable/>`_
425 module (version at least 2.4), recompiling the Python bindings from
426 the source should be as easy as:
427
428 .. code-block:: console
429
430   # cd simgrid-source-tree
431   $ python setup.py build install
432
433 Starting with SimGrid 3.13, it should even be possible to install
434 simgrid without downloading the source with pip:
435
436 .. code-block:: console
437
438   $ pip install simgrid
439
440 If you installed SimGrid to a non-standard directory (such as ``/opt/simgrid`` as advised earlier), you should tell python where
441 to find the libraries as follows (notice the elements suffixed to the configured prefix).
442
443 .. code-block:: console
444
445   $ PYTHONPATH="/opt/simgrid/lib/python3/dist-packages" LD_LIBRARY_PATH="/opt/simgrid/lib" python your_script.py
446
447 You can add those variables to your bash profile to not specify it each time by adding these lines to your ``~/.profile``:
448
449 .. code-block:: console
450
451   export PYTHONPATH="$PYTHONPATH:/opt/simgrid/lib/python3/dist-packages"
452   export LD_LIBRARY_PATH="$PYTHONPATH:/opt/simgrid/lib"