Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
10d3360b6a1ca3833d918b6da49fe32678763612
[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_latency_bound_tracking</b> (ON/OFF): enable it if you
220       want to be warned when communications are limited by round trip
221       time while doing packet-level simulation.
222   @li <b>enable_documentation</b> (ON/OFF) : whether the documentation should be
223        generated during the compilation. Default is ON.
224
225 \subsubsection install_cmake_reset Resetting the compilation configuration
226
227 If you need to empty the cache of values saved by cmake (either
228 because you added a new library or because something seriously went
229 wrong), you can simply delete the file CMakeCache.txt that is created
230 at the root of the source tree. You may also want to edit this file
231 directly in some circumstances.
232
233 \subsubsection install_cmake_outsrc Compiling into a separate directory
234
235 By default, the files produced during the compilation are placed in
236 the source directory. As the compilation generates a lot of files, it
237 is advised to to put them all in a separate directory. It is then
238 easier to cleanup, and this allows to compile several configurations
239 out of the same source tree. For that, simply enter the directory
240 where you want the produced files to land, and invoke cmake (or
241 ccmake) with the full path to the SimGrid source as last argument.
242 This approach is called "compilation out of source tree".
243
244 @verbatim
245 mkdir build
246 cd build
247 cmake [options] ..
248 make
249 @endverbatim
250
251 \subsubsection install_cmake_mac Building on Mac OS X
252
253 SimGrid compiles like a charm with clang (version 3.0 or higher) on Mac OS X:
254
255 @verbatim
256 cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
257 make
258 @endverbatim
259
260 With the XCode version of clang 4.1, you may get the following error message:
261 @verbatim
262 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
263 @endverbatim
264
265 In that case, edit the CMakeCache.txt file directly, so that the
266 CMAKE_OSX_SYSROOT is similar to the following. Don't worry about the
267 warning that the "-pthread" argument is not used, if it appears.
268 @verbatim
269 CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer
270 @endverbatim
271
272 In the El Capitan version of Max OS X, Apple decided that users don't
273 need no /usr/include directory anymore. If you are hit by this pure
274 madness, just run the following command to restore that classical
275 UNIX directory: `xcode-select -install`
276
277 \subsubsection install_cmake_windows Building on Windows
278
279 Building from the source on Windows, may be something of an adventure.
280 We never managed to compile SimGrid with something else than MinGW-64
281 ourselves. We usually use the
282 <a href="http://www.activestate.com/activeperl/downloads">activestate</a>
283 version of Perl, and the
284 <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">msys</a>
285 version of git on this architecture, but YMMV. You can have a look at
286 the configuration scripts in the appveyor.yml file, but you are
287 basically on your own here. Sorry. We are not fluent with Windows so
288 we cannot really help. 
289
290 The drawback of MinGW-64 is that the produced DLL are not compatible
291 with MS Visual C. If you need it, <a href="http://clang.llvm.org/docs/MSVCCompatibility.html">clang-cl</a>
292 sounds promising. If you manage to get something working, please tell
293 us how you achieved it.
294
295 \subsection install_src_compil SimGrid main compilation targets
296
297 In most cases, compiling and installing SimGrid is enough:
298
299 @verbatim
300 make
301 make install # try "sudo make install" if you don't have the permission to write
302 @endverbatim
303
304 In addition, several compilation targets are provided in SimGrid. If
305 your system is well configured, the full list of targets is available
306 for completion when using the Tab key. Note that some of the existing
307 targets are not really for public consumption so don't worry if some
308 stuff don't work for you.
309
310 @verbatim
311 make simgrid                    Build only the SimGrid library and not any example
312 make masterslave                Build only this example (and its dependencies)
313 make clean                      Clean the results of a previous compilation
314 make install                    Install the project (doc/ bin/ lib/ include/)
315 make uninstall                  Uninstall the project (doc/ bin/ lib/ include/)
316 make dist                       Build a distribution archive (tgz)
317 make distcheck                  Check the dist (make + make dist + tests on the distribution)
318 make doc                        Create SimGrid documentation
319 @endverbatim
320
321 If you want to see what is really happening, try adding VERBOSE=1 to
322 your compilation requests:
323
324 @verbatim
325 make VERBOSE=1
326 @endverbatim
327
328 @subsection install_src_test Testing SimGrid
329
330 Once everything is built, you may want to test the result. SimGrid
331 comes with an extensive set of regression tests (see @ref
332 inside_tests "that page of the insider manual" for more
333 details). Running the tests is done using the ctest binary that comes
334 with cmake. These tests are run for every commit and the result is
335 publicly <a href="https://ci.inria.fr/simgrid/">available</a>.
336
337 \verbatim
338 ctest                     # Launch all tests
339 ctest -R msg              # Launch only the tests which name match the string "msg"
340 ctest -j4                 # Launch all tests in parallel, at most 4 at the same time
341 ctest --verbose           # Display all details on what's going on
342 ctest --output-on-failure # Only get verbose for the tests that fail
343
344 ctest -R msg- -j5 --output-on-failure # You changed MSG and want to check that you didn't break anything, huh?
345                                       # That's fine, I do so all the time myself.
346 \endverbatim
347
348 \section install_setting_own Setting up your own code
349
350 \subsection install_setting_MSG MSG code on Unix
351
352 Do not build your simulator by modifying the SimGrid examples.  Go
353 outside the SimGrid source tree and create your own working directory
354 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
355
356 Suppose your simulation has the following structure (remember it is
357 just an example to illustrate a possible way to compile everything;
358 feel free to organize it as you want).
359
360 \li <tt>sched.h</tt>: a description of the core of the
361     scheduler (i.e. which functions are can be used by the
362     agents). For example we could find the following functions
363     (master, forwarder, slave).
364 \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
365     implementing the core of the scheduler. Most of these
366     functions use the MSG functions defined in section \ref
367     msg_task_usage.
368 \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
369     the MSG initialization (MSG_init()), the platform
370     creation (e.g. with MSG_create_environment()), the
371     deployment phase (e.g. with MSG_function_register() and
372     MSG_launch_application()) and the call to MSG_main()).
373
374 To compile such a program, we suggest to use the following
375 Makefile. It is a generic Makefile that we have used many times with
376 our students when we teach the C language.
377
378 \verbatim
379 all: masterslave
380 masterslave: masterslave.o sched.o
381
382 INSTALL_PATH = $$HOME
383 CC = gcc
384 PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
385                                 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
386                                 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
387                                 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
388                                 -Wpointer-arith -Wwrite-strings -finline-functions
389 REASONABLY_CAREFUL_DUDE =       -Wall
390 NO_PRAYER_FOR_THE_WICKED =      -w -O2
391 WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
392 CFLAGS = -g $(WARNINGS)
393
394 INCLUDES = -I$(INSTALL_PATH)/include
395 DEFS = -L$(INSTALL_PATH)/lib/
396 LDADD = -lm -lsimgrid
397 LIBS =
398
399 %: %.o
400         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@
401
402 %.o: %.c
403         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
404
405 clean:
406         rm -f $(BIN_FILES) *.o *~
407 .SUFFIXES:
408 .PHONY: clean
409
410 \endverbatim
411
412 The first two lines indicates what should be build when typing make
413 (<tt>masterslave</tt>) and of which files it is to be made of
414 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
415 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
416 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
417 the static version, remove the <tt>-lsimgrid</tt> and add a
418 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
419 after the <tt>LIBS = </tt>.
420
421 More generally, if you have never written a Makefile by yourself, type
422 in a terminal: <tt>info make</tt> and read the introduction. The
423 previous example should be enough for a first try but you may want to
424 perform some more complex compilations...
425
426
427 */