Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
629499ea1a61a73bb135e5b82cf99929e4ee58e8
[simgrid.git] / doc / doxygen / install.doc
1 /*!
2 @page install Installing Simgrid
3
4 @tableofcontents
5
6 The easiest way to install SimGrid is to go for a binary package.
7 Under Debian or Ubuntu, this is very easy as SimGrid is directly
8 integrated to the official repositories. Under Windows, SimGrid can be
9 installed in a few clicks once you downloaded the installer from
10 gforge. If you just want to use Java, simply copy the jar file on your
11 disk and you're set.
12
13 Recompiling an official archive is not much more complex, actually.
14 SimGrid has very few dependencies and rely only on very standard
15 tools.  First, download the *@SimGridRelease.tar.gz* archive
16 from [the download page](https://gforge.inria.fr/frs/?group_id=12).
17 Then, recompiling the archive should be done in a few lines:
18
19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh}
20 tar xf @SimGridRelease.tar.gz
21 cd @SimGridRelease
22 cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
23 make
24 make install
25 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
27 If you want to stay on the bleeding edge, you should get the latest
28 git version, and recompile it as you would do for an official archive.
29 Depending on the files you change in the source tree, some extra
30 tools may be needed.
31
32 @section install_binary Installing a binary package
33
34 @subsection install_binary_linux Binary packages for linux
35
36 Most of the developers use a Debian or Ubuntu system, and some of us
37 happen to be Debian Maintainers, so the packages for these systems are
38 well integrated with these systems and very up-to-date. To install them,
39 simply type:
40
41 @verbatim
42 apt-get install simgrid
43 @endverbatim
44
45 On other Linux variants, you probably want to go for a source install.
46 Please contact us if you want to contribute the build scripts for your
47 preferred distribution.
48
49 @subsection install_binary_win Installation wizard for Windows
50
51 Before starting the installation, make sure that you have the following dependencies:
52   @li cmake 2.8 <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
53   @li MinGW <a href="http://sourceforge.net/projects/mingw/files/MinGW/">(download page)</a>
54   @li perl <a href="http://www.activestate.com/activeperl/downloads">(download page)</a>
55   @li git <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">(download page)</a>
56
57 Then download the package <a href="https://gforge.inria.fr/frs/?group_id=12">SimGrid Installer</a>,
58 execute it and follow instructions.
59
60 @image html win_install_01.png Step 1: Accept the license.
61 @image html win_install_02.png Step 2: Select packets to install.
62 @image html win_install_03.png Step 3: Choice where to install packets previously selected. Please don't use spaces in path.
63 @image html win_install_04.png Step 4: Add CLASSPATH to environment variables.
64 @image html win_install_05.png Step 5: Add PATH to environment variables.
65 @image html win_install_06.png Step 6: Restart your computer to take in consideration environment variables.
66
67 @subsection install_binary_java Using the binary jar file
68
69 The easiest way to install the Java bindings of SimGrid is to grab the
70 jar file from the
71 <a href="https://gforge.inria.fr/frs/?group_id=12">Download page</a>,
72 and copy it in your classpath (typically, in the same directory than
73 your source code). If you go for that version, there is no need to
74 install the C library as it is bundled within the jar file. Actually,
75 only a bunch of architectures are supported this way to keep the
76 jar file size under control and because we don't have access to every
77 exotic architectures ourselves.
78
79 If the jarfile fails on you, complaining that your architecture is not
80 supported, drop us an email: we may extend the jarfile for you, if we
81 have access to your architecture to build SimGrid on it.
82
83 @section install_src Installing from source
84
85 @subsection install_src_deps Resolving the dependencies
86
87 SimGrid only uses very standard tools:
88   - C compiler, C++ compiler, make and friends.
89   - perl (but you may try to go without it)
90   - We use cmake to configure our compilation
91       (<a href="http://www.cmake.org/cmake/resources/software.html">download page</a>).
92       You need cmake version 2.8 or higher. You may want to use ccmake
93       for a graphical interface over cmake.
94   - LibBoost:
95     - osX: with <a href="http://www.finkproject.org/">fink</a>: `sudo fink install boost1.53.nopython`
96     - debian: `apt-get install libboost-dev`
97
98 On MacOSX, it is advised to use the clang compiler (version 3.0 or
99 higher), from either MacPort or XCode. If you insist on using gcc on
100 this system, you still need a recent version of this compiler, so you
101 need an unofficial gcc47 from MacPort because the version provided by
102 Apple is ways to ancient to suffice. See also @ref install_cmake_mac.
103
104 On Windows, it is strongly advised to use the
105 <a href="http://sourceforge.net/projects/mingw/files/MinGW/">MinGW
106 environment</a> to build SimGrid, with <a href="http://www.mingw.org/wiki/MSYS">
107 MSYS tools</a> installed. Any other compilers are not tested
108 (and thus probably broken). We usually use the
109 <a href="http://www.activestate.com/activeperl/downloads">activestate</a>
110 version of Perl, and the
111 <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">msys</a>
112 version of git on this architecture, but YMMV. See also @ref install_cmake_win.
113
114 @subsection install_src_fetch Retrieving the source
115
116 If you just want to use SimGrid, you should probably grab the latest
117 stable version available from the
118 <a href="https://gforge.inria.fr/frs/?group_id=12">download page</a>.
119 We do our best to release soon and release often, but sometimes you
120 need to install the developer version of SimGrid, directly from the
121 git repository. Avoid the git version if you are not sure, as it may
122 break on you, or even worse.
123
124 @verbatim
125 git clone git://scm.gforge.inria.fr/simgrid/simgrid.git simgrid
126 @endverbatim
127
128 @subsection install_src_config Configuring the build
129
130 Note that compile-time options are very different from @ref options
131 "run-time options".
132
133 \subsubsection install_cmake_howto Setting compilation options
134
135 The default configuration should be ok for most usages, but if you
136 need to change something, there is several ways to do so. First, you
137 can use environment variables. For example, you can change the used
138 compilers by issuing these commands before launching cmake:
139
140 @verbatim
141 export CC=gcc-4.7
142 export CXX=g++-4.7
143 @endverbatim
144
145 Note that other variables are available, such as CFLAGS and CXXFLAGS to add
146 options for respectively the C compiler and the C++ compiler.
147
148 Another way to do so is to use the -D argument of cmake as follows.
149 Note that the terminating dot is mandatory (see @ref
150 install_cmake_outsrc to understand its meaning).
151
152 @verbatim
153 cmake -DCC=clang -DCXX=clang++ .
154 @endverbatim
155
156 Finally, you can use a graphical interface such as ccmake to change
157 these settings. Simply follow the instructions after starting the
158 interface.
159
160 @verbatim
161 ccmake .
162 @endverbatim
163
164 \subsubsection install_cmake_list SimGrid compilation options
165
166 In addition to the classical cmake configuration variables, SimGrid
167 accepts several options, as listed below.
168
169   @li <b>CMAKE_INSTALL_PREFIX</b> (path): Where to install SimGrid
170       (e.g. /usr/local or /opt).
171
172   @li <b>enable_compile_optimizations</b> (ON/OFF): request the
173       compiler to produce efficient code. You want to activate it,
174       unless you want to debug SimGrid itself (as efficient code may
175       be appear mangled to the debuggers).
176
177   @li <b>enable_debug</b> (ON/OFF): disable this if simulation speed
178       really matters to you. All log messages of gravity debug or
179       below will be discarded at compilation time. Since there is
180       quite a bunch of such log messages in SimGrid itself, this can
181       reveal faster than discarding them at runtime as usually. But of
182       course, it is then impossible to get any debug message from
183       SimGrid if something goes wrong.
184
185   @li <b>enable_msg_deprecated</b> (ON/OFF): enable this option if
186       your code used a feature of Simgrid that was dropped or modified
187       in recent releases of SimGrid. You should update your code if
188       possible, but with this option, SimGrid will try to emulate its
189       old behavior.
190
191   @li <b>enable_model-checking</b> (ON/OFF): Only enable this if you
192       actually plan to use the model-checking aspect of SimGrid. This
193       mode of execution is still under heavy work, but it should be
194       rather usable now. Be <b>warned</b> that this option will hinder
195       your simulation speed even if you simulate without activating
196       the model-checker. We are working on improving this situation.
197
198   @li <b>enable_compile_warnings</b> (ON/OFF): request the compiler to
199       issue error message whenever the source code is not perfectly
200       clean. If you develop SimGrid itself, you must activate it to
201       ensure the code quality, but as a user, that option will only
202       bring you issues.
203
204   @li <b>enable_lib_static</b> (ON/OFF): enable this if you want to
205       compile the static library (but you should consider enjoying
206       this new century instead).
207
208   @li <b>enable_maintainer_mode</b> (ON/OFF): you only need to set
209       this option if you modify very specific parts of SimGrid itself
210       (the XML parsers and other related elements). Adds an extra
211       dependency on flex and flexml.
212
213   @li <b>enable_tracing</b> (ON/OFF): disable this if you have issues
214       with the tracing module. But this module is now very stable and
215       you really should try to enjoy this beauty.
216
217   @li <b>enable_smpi</b> (ON/OFF): disable this if you have issues
218       with the module allowing to run MPI code on top of SimGrid. This
219       module very stable, but if you really don't need it, you can
220       disable it.
221
222   @li <b>enable_mallocators</b> (ON/OFF): disable this when tracking
223       memory issues within SimGrid, or the caching mechanism used
224       internally will fool the debuggers.
225
226   @li <b>enable_jedule</b> (ON/OFF): enable this to get SimDag
227       producing traces that can then be visualized with the Jedule
228       external tool.
229
230   @li <b>enable_lua</b> (ON/OFF): enable this if you want to enjoy the
231       lua bindings of SimGrid. Adds an extra dependency on lua library
232       and developer header files.
233
234
235   @li <b>enable_ns3</b> (ON/OFF): whether you want to use ns3.
236       See section @ref pls_simgrid_configuration_ns3.
237   @li <b>NS3_HINT</b> (path): Where to search for NS3 (eg /usr or /opt).
238   @li <b>enable_latency_bound_tracking</b> (ON/OFF): enable it if you
239       want to be warned when communications are limited by round trip
240       time while doing packet-level simulation.
241   @li <b>enable_documentation</b> (ON/OFF) : whether the documentation should be
242        generated during the compilation. Default is ON.
243
244 \subsubsection install_cmake_reset Resetting the compilation configuration
245
246 If you need to empty the cache of values saved by cmake (either
247 because you added a new library or because something seriously went
248 wrong), you can simply delete the file CMakeCache.txt that is created
249 at the root of the source tree. You may also want to edit this file
250 directly in some circumstances.
251
252 \subsubsection install_cmake_outsrc Compiling into a separate directory
253
254 By default, the files produced during the compilation are placed in
255 the source directory. As the compilation generates a lot of files, it
256 is advised to to put them all in a separate directory. It is then
257 easier to cleanup, and this allows to compile several configurations
258 out of the same source tree. For that, simply enter the directory
259 where you want the produced files to land, and invoke cmake (or
260 ccmake) with the full path to the SimGrid source as last argument.
261 This approach is called "compilation out of source tree".
262
263 @verbatim
264 mkdir build
265 cd build
266 cmake [options] ..
267 make
268 @endverbatim
269
270 \subsubsection install_cmake_win Cmake on Windows (with MinGW + MSYS)
271
272 Cmake can produce several kind of of makefiles. Under Windows, it has
273 no way of determining what kind you want to use, so you have to hint it:
274
275 @verbatim
276 cmake -G "MSYS Makefiles" (other options) .
277 make
278 @endverbatim
279
280 \subsubsection install_cmake_mac Cmake on Mac OS X
281
282 SimGrid compiles like a charm with clang on Mac OS X:
283
284 @verbatim
285 cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
286 make
287 @endverbatim
288
289 With the XCode version of clang 4.1, you may get the following error message:
290 @verbatim
291 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
292 @endverbatim
293
294 In that case, edit the CMakeCache.txt file directly, so that the
295 CMAKE_OSX_SYSROOT is similar to the following. Don't worry about the
296 warning that the "-pthread" argument is not used, if it appears.
297 @verbatim
298 CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer
299 @endverbatim
300
301 \subsection install_src_compil Compiling SimGrid
302
303 In most cases, compiling and installing SimGrid is enough:
304
305 @verbatim
306 make
307 make install # try "sudo make install" if you don't have the permission to write
308 @endverbatim
309
310 In addition, several compilation targets are provided in SimGrid. If
311 your system is well configured, the full list of targets is available
312 for completion when using the Tab key. Note that some of the existing
313 targets are not really for public consumption so don't worry if some
314 stuff don't work for you.
315
316 @verbatim
317 make simgrid                    Build only the SimGrid library and not any example
318 make masterslave                Build only this example (and its dependencies)
319 make clean                      Clean the results of a previous compilation
320 make install                    Install the project (doc/ bin/ lib/ include/)
321 make uninstall                  Uninstall the project (doc/ bin/ lib/ include/)
322 make dist                       Build a distribution archive (tgz)
323 make distcheck                  Check the dist (make + make dist + tests on the distribution)
324 make doc                        Create SimGrid documentation
325 @endverbatim
326
327 If you want to see what is really happening, try adding VERBOSE=1 to
328 your compilation requests:
329
330 @verbatim
331 make VERBOSE=1
332 @endverbatim
333
334 @subsection install_src_test Testing SimGrid
335
336 Once everything is built, you may want to test the result. SimGrid
337 comes with an extensive set of regression tests (see @ref
338 inside_cmake_addtest "that page of the insider manual" for more
339 details). Running the tests is done using the ctest binary that comes
340 with cmake. These tests are run every night and the result is publicly
341 <a href="http://cdash.inria.fr/CDash/index.php?project=Simgrid">available</a>.
342
343 \verbatim
344 ctest                     # Launch all tests
345 ctest -D Experimental     # Launch all tests and report the result to
346                           # http://cdash.inria.fr/CDash/index.php?project=SimGrid
347 ctest -R msg              # Launch only the tests which name match the string "msg"
348 ctest -j4                 # Launch all tests in parallel, at most 4 at the same time
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 msg- -j5 --output-on-failure # You changed MSG and want to check that you didn't break anything, huh?
353                                       # That's fine, I do so all the time myself.
354 \endverbatim
355
356 \section install_setting_own Setting up your own code
357
358 \subsection install_setting_MSG MSG code on Unix (Linux or Mac OSX)
359
360 Do not build your simulator by modifying the SimGrid examples.  Go
361 outside the SimGrid source tree and create your own working directory
362 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
363
364 Suppose your simulation has the following structure (remember it is
365 just an example to illustrate a possible way to compile everything;
366 feel free to organize it as you want).
367
368 \li <tt>sched.h</tt>: a description of the core of the
369     scheduler (i.e. which functions are can be used by the
370     agents). For example we could find the following functions
371     (master, forwarder, slave).
372 \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
373     implementing the core of the scheduler. Most of these
374     functions use the MSG functions defined in section \ref
375     msg_task_usage.
376 \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
377     the MSG initialization (MSG_init()), the platform
378     creation (e.g. with MSG_create_environment()), the
379     deployment phase (e.g. with MSG_function_register() and
380     MSG_launch_application()) and the call to MSG_main()).
381
382 To compile such a program, we suggest to use the following
383 Makefile. It is a generic Makefile that we have used many times with
384 our students when we teach the C language.
385
386 \verbatim
387 all: masterslave
388 masterslave: masterslave.o sched.o
389
390 INSTALL_PATH = $$HOME
391 CC = gcc
392 PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
393                                 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
394                                 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
395                                 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
396                                 -Wpointer-arith -Wwrite-strings -finline-functions
397 REASONABLY_CAREFUL_DUDE =       -Wall
398 NO_PRAYER_FOR_THE_WICKED =      -w -O2
399 WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
400 CFLAGS = -g $(WARNINGS)
401
402 INCLUDES = -I$(INSTALL_PATH)/include
403 DEFS = -L$(INSTALL_PATH)/lib/
404 LDADD = -lm -lsimgrid
405 LIBS =
406
407 %: %.o
408         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@
409
410 %.o: %.c
411         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
412
413 clean:
414         rm -f $(BIN_FILES) *.o *~
415 .SUFFIXES:
416 .PHONY: clean
417
418 \endverbatim
419
420 The first two lines indicates what should be build when typing make
421 (<tt>masterslave</tt>) and of which files it is to be made of
422 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
423 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
424 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
425 the static version, remove the <tt>-lsimgrid</tt> and add a
426 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
427 after the <tt>LIBS = </tt>.
428
429 More generally, if you have never written a Makefile by yourself, type
430 in a terminal: <tt>info make</tt> and read the introduction. The
431 previous example should be enough for a first try but you may want to
432 perform some more complex compilations...
433
434
435 \subsection install_setting_win_provided Compile the "HelloWorld" project on Windows
436
437 In the SimGrid install directory you should have an HelloWorld project to explain you how to start
438 compiling a source file. There are:
439 \verbatim
440 - HelloWorld.c          The example source file.
441 - CMakeLists.txt        It allows to configure the project.
442 - README                This explanation.
443 \endverbatim
444
445 Now let's compile this example:
446 \li Run windows shell "cmd".
447 \li Open HelloWorld Directory ('cd' command line).
448 \li Create a build directory and change directory. (optional)
449 \li Type 'cmake -G"MinGW Makefiles" \<path_to_HelloWorld_project\>'
450 \li Run mingw32-make
451 \li You should obtain a runnable example ("HelloWorld.exe").
452
453 For compiling your own code you can simply copy the HelloWorld project and rename source name. It will
454 create a target with the same name of the source.
455
456
457 \subsection install_setting_win_new Adding and Compiling a new example on Windows
458
459 \li Put your source file into the helloWord directory.
460 \li Edit CMakeLists.txt by removing the Find Targets section and add those two lines into this section
461 \verbatim
462 ################
463 # FIND TARGETS #
464 ################
465 #It creates a target called 'TARGET_NAME.exe' with the sources 'SOURCES'
466 add_executable(TARGET_NAME SOURCES)
467 #Links TARGET_NAME with simgrid
468 target_link_libraries(TARGET_NAME simgrid)
469 \endverbatim
470 \li To initialize and build your project, you'll need to run
471 \verbatim
472 cmake -G"MinGW Makefiles" <path_to_HelloWorld_project>
473 \endverbatim
474 \li Run "mingw32-make"
475 \li You should obtain "TARGET_NAME.exe".
476
477 \subsection install_Win_ruby Setup a virtualbox to use SimGrid-Ruby on windows
478
479 Allan Espinosa made these set of Vagrant rules available so that you
480 can use the SimGrid Ruby bindings in a virtual machine using
481 VirtualBox. Thanks to him for that. You can find his project here:
482 https://github.com/aespinosa/simgrid-vagrant
483
484
485
486 */