Logo AND Algorithmique Numérique Distribuée

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