Logo AND Algorithmique Numérique Distribuée

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