Logo AND Algorithmique Numérique Distribuée

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