Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
721f9edb29b442b4b549bd64834dd015d2d9e3ba
[simgrid.git] / doc / doxygen / install.doc
1 /*! @page install Installing Simgrid
2
3 @tableofcontents
4
5 SimGrid should work out of the box on Linux, Mac OSX, FreeBSD, and Windows (under windows, only the Java interfaces are
6 available at the moment).
7
8 The easiest way to install SimGrid is to go for a @ref install_binary "binary package". Under Debian or Ubuntu, this is 
9 very easy as SimGrid is directly integrated to the official repositories. For other Linux variants, you probably want 
10 to go for a @ref install_src "source install". Please contact us if you want to contribute the build scripts for your 
11 preferred distribution. If you just want to use @ref install_binary_java "Java", simply copy the jar file on your disk 
12 and you're set.
13
14 @section install_binary Pre-compiled Packages
15
16 @subsection install_binary_linux Binaries for Linux
17
18 Most of us use a Debian or Ubuntu system, so the packages for these
19 systems are well integrated and up-to-date. To get these packages, simply type:
20
21 @verbatim
22 apt-get install simgrid
23 @endverbatim
24
25 @subsection install_binary_java Stable Java Package 
26
27 For the SimGrid Java bindings, grab the jar file from the [download
28 page](https://gforge.inria.fr/frs/?group_id=12) and copy it in your
29 classpath (typically, your source code root directory). This
30 self-contained version even includes the SimGrid native components for
31 the following architectures: Linux (Amd64, x86, Arm), Mac OS X 64
32 bits, Windows 64 bits, FreeBSD (64 bits).
33
34 @subsection install_binary_java_builder Nightly built Java Package
35
36 For Windows, head to [AppVeyor](https://ci.appveyor.com/project/mquinson/simgrid).
37 Click on the artefact link on the right, and grab your file. If the latest build failed, there will be no artefact. Then
38 you will need to first click on "History" on the top and search for the last successful build.
39
40 For non-Windows systems (Linux, Mac or FreeBSD), head to [Jenkins](https://ci.inria.fr/simgrid/job/SimGrid-Multi).
41 In the build history, pick the last green (or at least yellow) build that is not blinking (i.e., not currently under 
42 build). In the list, pick a system that is close to yours, and click on the ball in the Debug row. The build artefact 
43 will appear on the top of the resulting page.
44
45 @subsection install_binary_java_troubleshooting Binary Java Troubleshooting
46
47  - **Your architecture is not supported by this jarfile**. \n
48    If your system is in the list of the supported architectures (see
49    @ref install_binary_java "above"), then this is probably a bug that 
50    @ref contributing_bugs "you should report".\n
51    If your system is actually not supported, you should compile your
52    own jarfile @ref install_src "by compiling SimGrid" on your
53    machine. If you feel so, @ref contact "contact us" so that we add
54    your architecture to the list.
55
56  - **Library not found: boost-context**.\n 
57    You should obviously install the @c boost-context library on your
58    machine, for example with @c apt-get.
59
60 @section install_src Source Installs
61
62 @subsection install_src_deps Getting the Dependencies
63
64 Recompiling an official archive is not much more complex. SimGrid only uses very standard tools:
65   - C compiler, C++ compiler, make and friends.
66   - perl (but you may try to go without it)
67   - We use cmake to configure our compilation
68       ([download page](http://www.cmake.org/cmake/resources/software.html)).
69       You need cmake version 2.8.8 or higher. You may want to use ccmake
70       for a graphical interface over cmake.
71   - boost:
72     - Max OS X: with [fink](http://www.finkproject.org/): `fink install boost1.53.nopython`,
73       or with homebrew: `brew install boost`
74     - Debian / Ubuntu: `apt-get install libboost-dev libboost-context-dev`
75   - Java (if you want to build the Java bindings): Grab a
76     [full JDK](http://www.oracle.com/technetwork/java/javase/downloads)
77
78 For platform-specific details, please see  @ref install_cmake_mac,
79 @ref install_cmake_windows and @ref install_src_32bits
80
81 @subsection install_src_fetch Getting the Sources
82
83 You can download the *@SimGridRelease.tar.gz* archive from the 
84 [download page](https://gforge.inria.fr/frs/?group_id=12).
85 Then, recompiling the archive should be done in a few lines:
86
87 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh}
88 tar xf @SimGridRelease.tar.gz
89 cd @SimGridRelease
90 cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
91 make
92 make install
93 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94
95 If you want to stay on the bleeding edge, you should get the latest git version, and recompile it as you would do for 
96 an official archive. Depending on the files you change in the source tree, some extra tools may be needed.
97
98 @verbatim
99 git clone git://scm.gforge.inria.fr/simgrid/simgrid.git simgrid
100 @endverbatim
101
102 @subsection install_src_config Build Configuration
103
104 Note that compile-time options are very different from @ref options "run-time options".
105
106 @subsubsection install_cmake_howto Compilation Options
107
108 The default configuration should be fine for most usages, but if you need to change something, there are several ways 
109 to do so. First, you can use environment variables. For example, you can change the compilers used by issuing these 
110 commands before launching cmake:
111
112 @verbatim
113 export CC=gcc-4.7
114 export CXX=g++-4.7
115 @endverbatim
116
117 Note that other variables are available, such as CFLAGS and CXXFLAGS to add options respectively for the C and C++ 
118 compilers.
119
120 Another way to do so is to use the -D argument of cmake as follows.
121 Note that the ending dot is mandatory (see @ref install_cmake_outsrc).
122
123 @verbatim
124 cmake -DCC=clang -DCXX=clang++ .
125 @endverbatim
126
127 Finally, you can use the ccmake graphical interface to change these settings. 
128
129 @verbatim
130 ccmake .
131 @endverbatim
132
133 @subsubsection install_cmake_list SimGrid compilation options
134
135 In addition to the classical cmake configuration variables, SimGrid accepts several options, as listed below.
136
137   @li <b>CMAKE_INSTALL_PREFIX</b> (path): Where to install SimGrid (/opt/simgrid, /usr/local, or elsewhere).
138
139   @li <b>enable_compile_optimizations</b> (ON/OFF) to request the compiler to produce efficient code. You want to 
140       activate it, unless you plan to debug SimGrid itself. Indeed, efficient code may be appear mangled to debuggers.
141
142   @li <b>enable_compile_warnings</b> (ON/OFF) to request the compiler to issue error messages whenever the source code
143       is not perfectly clean. If you are a SimGrid developer, you have to activate this option to enforce the code 
144       quality. As a regular user, this option will bring you nothing.
145
146   @li <b>enable_debug</b> (ON/OFF). Disable this option toto discard
147       all log messages of gravity debug or below at compile time (see
148       @ref XBT_log). The resulting code is faster than if you
149       discarding these messages at runtime. However, it obviously
150       becomes impossible to get any debug info from SimGrid if
151       something goes wrong.
152
153   @li <b>enable_documentation</b> (ON/OFF) to generate the documentation pages.
154
155   @li <b>enable_java</b> (ON/OFF) to enjoy the java bindings of SimGrid.
156
157   @li <b>enable_jedule</b> (ON/OFF) to get SimDag producing execution traces that can then be visualized with the 
158       Jedule external tool.
159
160   @li <b>enable_lua</b> (ON/OFF) to enjoy the lua bindings to the
161       SimGrid internals.
162
163   @li <b>enable_lib_in_jar</b> (ON/OFF) to make sure that the native
164       java bindings are bundled in the jar file.
165
166   @li <b>enable_lto</b> (ON/OFF) to enable the Link Time Optimization
167       of the C compiler. This feature really speeds up the produced
168       code, but it is fragile with some versions of GCC.
169
170   @li <b>enable_maintainer_mode</b> (ON/OFF) is only needed if you plan to modify very specific parts of SimGrid
171       (e.g., the XML parsers and other related elements). Moreover, this adds an extra dependency on flex and flexml.
172
173   @li <b>enable_mallocators</b> (ON/OFF) has to be disabled when tracking memory issues within SimGrid, or the caching 
174       mechanism used internally will fool the debuggers.
175
176   @li <b>enable_model-checking</b> (ON/OFF) if you actually plan to
177       use the model-checking feature of SimGrid. This execution mode
178       is very usable now, but enabling this option at compile time
179       will **hinder simulation speed** even when the model-checker is
180       not activated at run time.
181
182   @li <b>enable_ns3</b> (ON/OFF) if you want to use ns-3. See section @ref pls_simgrid_configuration_ns3.
183
184   @li <b>enable_smpi</b> (ON/OFF) to run MPI code on top of SimGrid.
185
186   @li <b>enable_smpi_ISP_testsuite</b> (ON/OFF) to add many extra
187       tests for the model-checker module.
188
189   @li <b>enable_smpi_MPICH3_testsuite</b> (ON/OFF) to add many extra
190       tests for the MPI module.
191
192 @subsubsection install_cmake_reset Reset the build configuration
193
194 To empty the cmake cache (either when you add a new library or when
195 things go seriously wrong), simply delete your @c CMakeCache.txt. You
196 may also want to directly edit this file in some circumstances.
197
198 @subsubsection install_cmake_outsrc Out of Tree Compilation
199
200 By default, the files produced during the compilation are placed in
201 the source directory. It is however often better to put them all in a
202 separate directory: cleaning the tree becomes as easy as removing this
203 directory, and you can have several such directories to test several
204 parameter sets or architectures.
205
206 For that, go to the directory where the files should be produced, and
207 invoke cmake (or ccmake) with the full path to the SimGrid source as
208 last argument.
209
210 @verbatim
211 mkdir build
212 cd build
213 cmake [options] ..
214 make
215 @endverbatim
216
217 @subsubsection install_cmake_mac Mac OS X Builds
218
219 SimGrid compiles like a charm with clang (version 3.0 or higher) on Mac OS X:
220
221 @verbatim
222 cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
223 make
224 @endverbatim
225
226 With the XCode version of clang 4.1, you may get the following error message:
227 @verbatim
228 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
229 @endverbatim
230
231 In that case, edit the CMakeCache.txt file directly, so that the
232 CMAKE_OSX_SYSROOT is similar to the following. Don't worry about the
233 warning that the "-pthread" argument is not used, if it appears.
234 @verbatim
235 CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer
236 @endverbatim
237
238 In the El Capitan version of Max OS X, Apple decided that users don't
239 need no /usr/include directory anymore. If you are hit by this pure
240 madness, just run the following command to restore that classical
241 UNIX directory: `xcode-select -install`
242
243 @subsubsection install_cmake_windows Windows Builds
244
245 Building SimGrid on Windows may be something of an adventure:
246 We only manage to  do so ourselves with MinGW-64, <a
247 href="http://www.activestate.com/activeperl/downloads">ActiveState</a>
248 Perl and <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">msys</a>
249 git). Have a look at out configuration scripts in @c appveyor.yml, but
250 don't expect too much  from us: we are really not fluent with Windows.
251 Actually your help is welcome.
252
253 The drawback of MinGW-64 is that the produced DLL are not compatible
254 with MS Visual C. <a href="http://clang.llvm.org/docs/MSVCCompatibility.html">clang-cl</a>
255 sounds promising to fix this. If you get something working, please
256 @ref contact "tell us".
257
258 @subsubsection install_src_32bits 32 bits Builds on Multi-arch Linux
259
260 On a multiarch x86_64 Linux, it should be possible to compile a 32 bit
261 version of SimGrid with something like:
262
263 @verbatim
264 CFLAGS=-m32 \
265 CXXFLAGS=-m32 \
266 PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig/ \
267 cmake . \
268 -DCMAKE_SYSTEM_PROCESSOR=i386 \
269 -DCMAKE_Fortran_COMPILER=/some/path/to/i686-linux-gnu-gfortran \
270 -DGFORTRAN_EXE=/some/path/to/i686-linux-gnu-gfortran \
271 -DCMAKE_Fortran_FLAGS=-m32
272 @endverbatim
273
274 If needed, implement @c i686-linux-gnu-gfortran as a script:
275
276 @verbatim
277 #!/bin/sh
278 exec gfortran -m32 "$@"
279 @endverbatim
280
281 @subsection install_src_compil Existing Compilation Targets
282
283 In most cases, compiling and installing SimGrid is enough:
284
285 @verbatim
286 make
287 make install # try "sudo make install" if you don't have the permission to write
288 @endverbatim
289
290 In addition, several compilation targets are provided in SimGrid. If
291 your system is well configured, the full list of targets is available
292 for completion when using the Tab key. Note that some of the existing
293 targets are not really for public consumption so don't worry if some
294 stuff doesn't work for you.
295
296 @verbatim
297 make simgrid                    Build only the SimGrid library and not any example
298 make app-masterworker           Build only this example (works for any example)
299 make clean                      Clean the results of a previous compilation
300 make install                    Install the project (doc/ bin/ lib/ include/)
301 make uninstall                  Uninstall the project (doc/ bin/ lib/ include/)
302 make dist                       Build a distribution archive (tgz)
303 make distcheck                  Check the dist (make + make dist + tests on the distribution)
304 make documentation              Create SimGrid documentation
305 @endverbatim
306
307 If you want to see what is really happening, try adding VERBOSE=1 to
308 your compilation requests:
309
310 @verbatim
311 make VERBOSE=1
312 @endverbatim
313
314 @subsection install_src_test Testing your build
315
316 Once everything is built, you may want to test the result. SimGrid
317 comes with an extensive set of regression tests (as described in the
318 @ref inside_tests "insider manual"). The tests are run with @c ctest, that comes with CMake.
319 We run them every commit and the results are on [our
320 Jenkins](https://ci.inria.fr/simgrid/).
321
322 @verbatim
323 ctest                     # Launch all tests
324 ctest -R msg              # Launch only the tests which name match the string "msg"
325 ctest -j4                 # Launch all tests in parallel, at most 4 at the same time
326 ctest --verbose           # Display all details on what's going on
327 ctest --output-on-failure # Only get verbose for the tests that fail
328
329 ctest -R msg- -j5 --output-on-failure # You changed MSG and want to check that you didn't break anything, huh?
330                                       # That's fine, I do so all the time myself.
331 @endverbatim
332
333 @section install_setting_own Setting up your own code
334
335 Directly modifying the SimGrid examples will make it harder to upgrade
336 to the next version of SimGrid. Instead, you should create your own
337 working directory somewhere on your disk
338 (say `/home/joe/MyFirstScheduler/`).
339
340 Here is a Makefile that will work if your project is composed of three
341 C files named @c util.h, @c util.c and @c mysimulator.c. You should
342 take it as a starting point, and adapt it to your code. There is a
343 plenty of documentation and tutorial on Makefile if the file's
344 comments are not enough for you.
345
346 @verbatim
347 # The first rule of a Makefile is the default target. It will be built when make is called with no parameter
348 # Here, we want to build the binary 'mysimulator'
349 all: mysimulator
350
351 # This second rule lists the dependencies of the mysimulator binary
352 # How this dependencies are linked is described in an implicit rule below
353 mysimulator: mysimulator.o util.o
354
355 # These third give the dependencies of the each source file
356 mysimulator.o: mysimulator.c util.h # list every .h that you use
357 util.o: util.c util.h
358
359 # Some configuration
360 SIMGRID_INSTALL_PATH = /opt/simgrid # Where you installed simgrid
361 CC = gcc                            # Your compiler
362 WARNING = -Wshadow -Wcast-align -Waggregate-return -Wmissing-prototypes \
363           -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes \
364           -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls \
365           -Wnested-externs -Wpointer-arith -Wwrite-strings -finline-functions
366
367 # CFLAGS = -g -O0 $(WARNINGS) # Use this line to make debugging easier
368 CFLAGS = -g -O2 $(WARNINGS) # Use this line to get better performance
369
370 # No change should be mandated past that line
371 #############################################
372 # The following are implicit rules, used by default to actually build
373 # the targets for which you listed the dependencies above.
374
375 # The blanks before the $(CC) must be a Tab char, not spaces
376 %: %.o
377         $(CC) -L$(SIMGRID_INSTALL_PATH)/lib/    $(CFLAGS) $^ -lsimgrid -o $@
378 %.o: %.c
379         $(CC) -I$(SIMGRID_INSTALL_PATH)/include $(CFLAGS) -c -o $@ $<
380
381 clean:
382         rm -f *.o *~
383 .PHONY: clean
384 @endverbatim
385
386 @subsection install_setting_own_trouble Troubleshooting your code setup
387
388 Sometimes, the following error message (or similar) will be produced.
389 @verbatim
390 masterworker.c:209: undefined reference to `sg_version_check'
391 masterworker.c:209: undefined reference to `MSG_init_nocheck'
392 (and possibly many other undefined references)
393 @endverbatim
394
395 It means that the system does not manage to find simgrid when it tries
396 to execute your programs. Specify where to search with the
397 <tt>LD_LIBRARY_PATH</tt> variable. Try running the following command
398 before executing your code. If it helps, you should add this line to
399 your ~/.bashrc so that it gets executed each time you log into your
400 computer.
401
402 @verbatim
403 export LD_LIBRARY_PATH=/opt/simgrid/lib
404 @endverbatim
405
406
407 */