Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / doc / doxygen / install.doc
1 /*!
2 @page install Installing Simgrid
3
4 @tableofcontents
5
6 SimGrid should work out of the box on Linux, Mac OSX, FreeBSD and
7 Windows (under windows, only the Java interfaces are available atm).
8
9 The easiest way to install SimGrid is to go for a binary package.
10 Under Debian or Ubuntu, this is very easy as SimGrid is directly
11 integrated to the official repositories.  If you just want to use
12 Java, simply copy the jar file on your disk and you're set.
13
14 Recompiling an official archive is not much more complex, actually.
15 SimGrid has very few dependencies and rely only on very standard
16 tools.  First, download the *@SimGridRelease.tar.gz* archive
17 from [the download page](https://gforge.inria.fr/frs/?group_id=12).
18 Then, recompiling the archive should be done in a few lines:
19
20 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh}
21 tar xf @SimGridRelease.tar.gz
22 cd @SimGridRelease
23 cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
24 make
25 make install
26 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27
28 If you want to stay on the bleeding edge, you should get the latest
29 git version, and recompile it as you would do for an official archive.
30 Depending on the files you change in the source tree, some extra
31 tools may be needed.
32
33 @section install_binary Installing a binary package
34
35 @subsection install_binary_linux Binary packages for linux
36
37 Most of the developers use a Debian or Ubuntu system, and some of us
38 happen to be Debian Maintainers, so the packages for these systems are
39 well integrated with these systems and very up-to-date. To install them,
40 simply type:
41
42 @verbatim
43 apt-get install simgrid
44 @endverbatim
45
46 On other Linux variants, you probably want to go for a source install.
47 Please contact us if you want to contribute the build scripts for your
48 preferred distribution.
49
50 @subsection install_binary_java Using the binary jar file
51
52 The easiest way to install the Java bindings of SimGrid is to grab the
53 jar file from the
54 <a href="https://gforge.inria.fr/frs/?group_id=12">Download page</a>,
55 and copy it in your classpath (typically, in the same directory than
56 your source code). If you go for that version, there is no need to
57 install the C library as it is bundled within the jar file. Actually,
58 only a bunch of architectures are supported this way to keep the
59 jar file size under control and because we don't have access to every
60 exotic architectures ourselves.
61
62 If the jarfile fails on you, complaining that your architecture is not
63 supported, drop us an email: we may extend the jarfile for you, if we
64 have access to your architecture to build SimGrid on it.
65
66 If the error message is about the boost-context library, then you
67 should install that library on your machine. This is a known issue in
68 the 3.12 release that will be fixed in the next release.
69
70 You can retrieve a nightly build of the jar file from our autobuilders. 
71 For Windows, head to 
72 <a href="https://ci.appveyor.com/project/mquinson/simgrid">AppVeyor</a>.
73 Click on the artefact link on the right, and grab your file. If the
74 latest build failed, there will be no artefact so you will need to
75 first click on "History" on the top to search for the last successful
76 build.
77 For non-Windows systems (Linux, Mac or FreeBSD), head to 
78 <a href="https://ci.inria.fr/simgrid/job/SimGrid-Multi">Jenkins</a>.
79 In the build history, pick the last green (or at least yellow) build
80 that is not blinking (ie, that is done building). In the list, pick a
81 system that is close to your system, and click on the ball in the
82 Debug row. The build artefact appear on the top of the resulting page.
83
84 @section install_src Installing from source
85
86 @subsection install_src_deps Resolving the dependencies
87
88 SimGrid only uses very standard tools:
89   - C compiler, C++ compiler, make and friends.
90   - perl (but you may try to go without it)
91   - We use cmake to configure our compilation
92       (<a href="http://www.cmake.org/cmake/resources/software.html">download page</a>).
93       You need cmake version 2.8.8 or higher. You may want to use ccmake
94       for a graphical interface over cmake.
95   - LibBoost:
96     - osX: with <a href="http://www.finkproject.org/">fink</a>: `fink install boost1.53.nopython`,
97       or with homebrew: `brew install boost`
98     - debian: `apt-get install libboost-dev libboost-context-dev`
99   - Java (only needed if you want to use the Java bindings): Grab a
100     full JDK from http://www.oracle.com/technetwork/java/javase/downloads
101
102 For platform specific details, please see  @ref install_cmake_mac and
103 @ref install_cmake_windows.
104
105 @subsection install_src_fetch Retrieving the source
106
107 If you just want to use SimGrid, you should probably grab the latest
108 stable version available from the
109 <a href="https://gforge.inria.fr/frs/?group_id=12">download page</a>.
110 We do our best to release soon and release often, but sometimes you
111 need to install the developer version of SimGrid, directly from the
112 git repository. Avoid the git version if you are not sure, as it may
113 break on you, or even worse.
114
115 @verbatim
116 git clone git://scm.gforge.inria.fr/simgrid/simgrid.git simgrid
117 @endverbatim
118
119 @subsection install_src_config Configuring the build
120
121 Note that compile-time options are very different from @ref options
122 "run-time options".
123
124 \subsubsection install_cmake_howto Setting compilation options
125
126 The default configuration should be ok for most usages, but if you
127 need to change something, there is several ways to do so. First, you
128 can use environment variables. For example, you can change the used
129 compilers by issuing these commands before launching cmake:
130
131 @verbatim
132 export CC=gcc-4.7
133 export CXX=g++-4.7
134 @endverbatim
135
136 Note that other variables are available, such as CFLAGS and CXXFLAGS to add
137 options for respectively the C compiler and the C++ compiler.
138
139 Another way to do so is to use the -D argument of cmake as follows.
140 Note that the terminating dot is mandatory (see @ref
141 install_cmake_outsrc to understand its meaning).
142
143 @verbatim
144 cmake -DCC=clang -DCXX=clang++ .
145 @endverbatim
146
147 Finally, you can use a graphical interface such as ccmake to change
148 these settings. Simply follow the instructions after starting the
149 interface.
150
151 @verbatim
152 ccmake .
153 @endverbatim
154
155 \subsubsection install_cmake_list SimGrid compilation options
156
157 In addition to the classical cmake configuration variables, SimGrid
158 accepts several options, as listed below.
159
160   @li <b>CMAKE_INSTALL_PREFIX</b> (path): Where to install SimGrid
161       (e.g. /usr/local or /opt).
162
163   @li <b>enable_compile_optimizations</b> (ON/OFF): request the
164       compiler to produce efficient code. You want to activate it,
165       unless you want to debug SimGrid itself (as efficient code may
166       be appear mangled to the debuggers).
167
168   @li <b>enable_debug</b> (ON/OFF): disable this if simulation speed
169       really matters to you. All log messages of gravity debug or
170       below will be discarded at compilation time. Since there is
171       quite a bunch of such log messages in SimGrid itself, this can
172       reveal faster than discarding them at runtime as usually. But of
173       course, it is then impossible to get any debug message from
174       SimGrid if something goes wrong.
175
176   @li <b>enable_model-checking</b> (ON/OFF): Only enable this if you
177       actually plan to use the model-checking aspect of SimGrid. This
178       mode of execution is still under heavy work, but it should be
179       rather usable now. Be <b>warned</b> that this option will hinder
180       your simulation speed even if you simulate without activating
181       the model-checker. We are working on improving this situation.
182
183   @li <b>enable_compile_warnings</b> (ON/OFF): request the compiler to
184       issue error message whenever the source code is not perfectly
185       clean. If you develop SimGrid itself, you must activate it to
186       ensure the code quality, but as a user, that option will only
187       bring you issues.
188
189   @li <b>enable_maintainer_mode</b> (ON/OFF): you only need to set
190       this option if you modify very specific parts of SimGrid itself
191       (the XML parsers and other related elements). Adds an extra
192       dependency on flex and flexml.
193
194   @li <b>enable_tracing</b> (ON/OFF): disable this if you have issues
195       with the tracing module. But this module is now very stable and
196       you really should try to enjoy this beauty.
197
198   @li <b>enable_smpi</b> (ON/OFF): disable this if you have issues
199       with the module allowing to run MPI code on top of SimGrid. This
200       module very stable, but if you really don't need it, you can
201       disable it.
202
203   @li <b>enable_mallocators</b> (ON/OFF): disable this when tracking
204       memory issues within SimGrid, or the caching mechanism used
205       internally will fool the debuggers.
206
207   @li <b>enable_jedule</b> (ON/OFF): enable this to get SimDag
208       producing traces that can then be visualized with the Jedule
209       external tool.
210
211   @li <b>enable_lua</b> (ON/OFF): enable this if you want to enjoy the
212       lua bindings of SimGrid. Adds an extra dependency on lua library
213       and developer header files.
214
215
216   @li <b>enable_ns3</b> (ON/OFF): whether you want to use ns3.
217       See section @ref pls_simgrid_configuration_ns3.
218   @li <b>NS3_HINT</b> (path): Where to search for NS3 (eg /usr or /opt).
219   @li <b>enable_documentation</b> (ON/OFF) : whether the documentation should be
220        generated during the compilation. Default is ON.
221
222 \subsubsection install_cmake_reset Resetting the compilation configuration
223
224 If you need to empty the cache of values saved by cmake (either
225 because you added a new library or because something seriously went
226 wrong), you can simply delete the file CMakeCache.txt that is created
227 at the root of the source tree. You may also want to edit this file
228 directly in some circumstances.
229
230 \subsubsection install_cmake_outsrc Compiling into a separate directory
231
232 By default, the files produced during the compilation are placed in
233 the source directory. As the compilation generates a lot of files, it
234 is advised to to put them all in a separate directory. It is then
235 easier to cleanup, and this allows to compile several configurations
236 out of the same source tree. For that, simply enter the directory
237 where you want the produced files to land, and invoke cmake (or
238 ccmake) with the full path to the SimGrid source as last argument.
239 This approach is called "compilation out of source tree".
240
241 @verbatim
242 mkdir build
243 cd build
244 cmake [options] ..
245 make
246 @endverbatim
247
248 \subsubsection install_cmake_mac Building on Mac OS X
249
250 SimGrid compiles like a charm with clang (version 3.0 or higher) on Mac OS X:
251
252 @verbatim
253 cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
254 make
255 @endverbatim
256
257 With the XCode version of clang 4.1, you may get the following error message:
258 @verbatim
259 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
260 @endverbatim
261
262 In that case, edit the CMakeCache.txt file directly, so that the
263 CMAKE_OSX_SYSROOT is similar to the following. Don't worry about the
264 warning that the "-pthread" argument is not used, if it appears.
265 @verbatim
266 CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer
267 @endverbatim
268
269 In the El Capitan version of Max OS X, Apple decided that users don't
270 need no /usr/include directory anymore. If you are hit by this pure
271 madness, just run the following command to restore that classical
272 UNIX directory: `xcode-select -install`
273
274 \subsubsection install_cmake_windows Building on Windows
275
276 Building from the source on Windows, may be something of an adventure.
277 We never managed to compile SimGrid with something else than MinGW-64
278 ourselves. We usually use the
279 <a href="http://www.activestate.com/activeperl/downloads">activestate</a>
280 version of Perl, and the
281 <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">msys</a>
282 version of git on this architecture, but YMMV. You can have a look at
283 the configuration scripts in the appveyor.yml file, but you are
284 basically on your own here. Sorry. We are not fluent with Windows so
285 we cannot really help. 
286
287 The drawback of MinGW-64 is that the produced DLL are not compatible
288 with MS Visual C. If you need it, <a href="http://clang.llvm.org/docs/MSVCCompatibility.html">clang-cl</a>
289 sounds promising. If you manage to get something working, please tell
290 us how you achieved it.
291
292 \subsection install_src_compil SimGrid main compilation targets
293
294 In most cases, compiling and installing SimGrid is enough:
295
296 @verbatim
297 make
298 make install # try "sudo make install" if you don't have the permission to write
299 @endverbatim
300
301 In addition, several compilation targets are provided in SimGrid. If
302 your system is well configured, the full list of targets is available
303 for completion when using the Tab key. Note that some of the existing
304 targets are not really for public consumption so don't worry if some
305 stuff don't work for you.
306
307 @verbatim
308 make simgrid                    Build only the SimGrid library and not any example
309 make masterslave                Build only this example (and its dependencies)
310 make clean                      Clean the results of a previous compilation
311 make install                    Install the project (doc/ bin/ lib/ include/)
312 make uninstall                  Uninstall the project (doc/ bin/ lib/ include/)
313 make dist                       Build a distribution archive (tgz)
314 make distcheck                  Check the dist (make + make dist + tests on the distribution)
315 make doc                        Create SimGrid documentation
316 @endverbatim
317
318 If you want to see what is really happening, try adding VERBOSE=1 to
319 your compilation requests:
320
321 @verbatim
322 make VERBOSE=1
323 @endverbatim
324
325 @subsection install_src_test Testing SimGrid
326
327 Once everything is built, you may want to test the result. SimGrid
328 comes with an extensive set of regression tests (see @ref
329 inside_tests "that page of the insider manual" for more
330 details). Running the tests is done using the ctest binary that comes
331 with cmake. These tests are run for every commit and the result is
332 publicly <a href="https://ci.inria.fr/simgrid/">available</a>.
333
334 \verbatim
335 ctest                     # Launch all tests
336 ctest -R msg              # Launch only the tests which name match the string "msg"
337 ctest -j4                 # Launch all tests in parallel, at most 4 at the same time
338 ctest --verbose           # Display all details on what's going on
339 ctest --output-on-failure # Only get verbose for the tests that fail
340
341 ctest -R msg- -j5 --output-on-failure # You changed MSG and want to check that you didn't break anything, huh?
342                                       # That's fine, I do so all the time myself.
343 \endverbatim
344
345 \section install_setting_own Setting up your own code
346
347 \subsection install_setting_MSG MSG code on Unix
348
349 Do not build your simulator by modifying the SimGrid examples.  Go
350 outside the SimGrid source tree and create your own working directory
351 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
352
353 Suppose your simulation has the following structure (remember it is
354 just an example to illustrate a possible way to compile everything;
355 feel free to organize it as you want).
356
357 \li <tt>sched.h</tt>: a description of the core of the
358     scheduler (i.e. which functions are can be used by the
359     agents). For example we could find the following functions
360     (master, forwarder, slave).
361 \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
362     implementing the core of the scheduler. Most of these
363     functions use the MSG functions defined in section \ref
364     msg_task_usage.
365 \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
366     the MSG initialization (MSG_init()), the platform
367     creation (e.g. with MSG_create_environment()), the
368     deployment phase (e.g. with MSG_function_register() and
369     MSG_launch_application()) and the call to MSG_main()).
370
371 To compile such a program, we suggest to use the following
372 Makefile. It is a generic Makefile that we have used many times with
373 our students when we teach the C language.
374
375 \verbatim
376 all: masterslave
377 masterslave: masterslave.o sched.o
378
379 INSTALL_PATH = $$HOME
380 CC = gcc
381 PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
382                                 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
383                                 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
384                                 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
385                                 -Wpointer-arith -Wwrite-strings -finline-functions
386 REASONABLY_CAREFUL_DUDE =       -Wall
387 NO_PRAYER_FOR_THE_WICKED =      -w -O2
388 WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
389 CFLAGS = -g $(WARNINGS)
390
391 INCLUDES = -I$(INSTALL_PATH)/include
392 DEFS = -L$(INSTALL_PATH)/lib/
393 LDADD = -lm -lsimgrid
394 LIBS =
395
396 %: %.o
397         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@
398
399 %.o: %.c
400         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
401
402 clean:
403         rm -f $(BIN_FILES) *.o *~
404 .SUFFIXES:
405 .PHONY: clean
406
407 \endverbatim
408
409 The first two lines indicates what should be build when typing make
410 (<tt>masterslave</tt>) and of which files it is to be made of
411 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
412 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
413 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
414 the static version, remove the <tt>-lsimgrid</tt> and add a
415 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
416 after the <tt>LIBS = </tt>.
417
418 More generally, if you have never written a Makefile by yourself, type
419 in a terminal: <tt>info make</tt> and read the introduction. The
420 previous example should be enough for a first try but you may want to
421 perform some more complex compilations...
422
423
424 */