Logo AND Algorithmique Numérique Distribuée

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