Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d78e20aaa982407c53991221f1c0e04cefe2e465
[simgrid.git] / doc / doxygen / install.doc
1 /*! 
2 \page install Installing Simgrid
3
4 \section install_cmake Installing the SimGrid library
5
6 \subsection install_installing_cmake Installing cmake
7
8 You must have cmake in order to compile SimGrid. If you cannot find a
9 binary package of cmake for your system, you'll need to recompile it.
10 In turn, cmake has a few dependencies:
11
12 For Unix and MacOS:
13   \li make
14   \li perl and libpcre
15   \li c and c++ compiler
16   \li ccmake for graphical used of CMake
17   \li cmake <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
18
19 On MacOSX some users reported that it is still possible to build with clang, provided that you
20 use at least clang3.0 installed with macport or with xcode. If it fails on you, try to
21  use gcc47.
22 \verbatim
23 port install clang-3.0
24 port install gcc47
25 \endverbatim
26
27 For Windows:
28   \li cmake 2.8 <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
29   \li MinGW <a href="http://sourceforge.net/projects/mingw/files/MinGW/">(download page)</a>
30   \li perl <a href="http://www.activestate.com/activeperl/downloads">(download page)</a>
31   \li git <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">(download page)</a>
32
33 Note that if you want change the compiler, you can simply specify the environment variables CC and CXX.
34 \verbatim
35         export CC=gcc-4.4
36         export CXX=g++-4.4
37         export CC=clang
38         export CXX=clang++
39 \endverbatim
40
41 \subsubsection install_cmakeoption1 SimGrid configuration options
42
43 \verbatim
44 "cmake -D[name]=[value] ... ./"
45
46 [name]  enable_gtnets           [value] ON/OFF or TRUE/FALSE or 1/0
47         enable_ns3                      ON/OFF or TRUE/FALSE or 1/0
48         enable_lua                      ON/OFF or TRUE/FALSE or 1/0
49         enable_compile_optimizations    ON/OFF or TRUE/FALSE or 1/0
50         enable_compile_warnings         ON/OFF or TRUE/FALSE or 1/0
51         enable_smpi                     ON/OFF or TRUE/FALSE or 1/0
52         enable_maintainer_mode          ON/OFF or TRUE/FALSE or 1/0
53         enable_tracing                  ON/OFF or TRUE/FALSE or 1/0
54         enable_coverage                 ON/OFF or TRUE/FALSE or 1/0
55         enable_memcheck                 ON/OFF or TRUE/FALSE or 1/0
56         enable_model-checking           ON/OFF or TRUE/FALSE or 1/0
57         enable_debug                    ON/OFF or TRUE/FALSE or 1/0
58         enable_jedule                   ON/OFF or TRUE/FALSE or 1/0
59         enable_latency_bound_tracking   ON/OFF or TRUE/FALSE or 1/0
60         enable_lib_static               ON/OFF or TRUE/FALSE or 1/0
61         enable_supernovae               ON/OFF or TRUE/FALSE or 1/0
62         enable_msg_deprecated           ON/OFF or TRUE/FALSE or 1/0
63         enable_print_message            ON/OFF or TRUE/FALSE or 1/0
64         gtnets_path                     <path_to_gtnets_directory>
65         ns3_path                        <path_to_ns3_directory>
66         CMAKE_INSTALL_PREFIX            <path_to_install_directory>
67         pipol_user                      <pipol_username>
68 \endverbatim
69
70   \li enable_gtnets: set to true implies that user wants to use gtnets.
71
72   \li enable_ns3: set to true implies that user wants to use ns3.
73
74   \li enable_lua: set to true implies that user wants to add lua language into simgrid compilation.
75
76   \li enable_compile_optimizations: add flags "-O3 -finline-functions -funroll-loops -fno-strict-aliasing"
77
78   \li enable_compile_warnings: add flags "-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror"
79
80   \li enable_smpi: Set to true if you want to use smpi lib. Actually on simgrid v3.4.1 Mac doesn't support lib smpi.
81
82   \li enable_maintainer_mode: set to true it remakes some files.
83
84   \li enable_tracing: To enable the generation of simulation traces for visualization.
85
86   \li enable_coverage: When set to true this option enable code coverage by setting -fprofile-arcs -ftest-coverage flags.
87
88   \li enable_memcheck: When set to true this option enable tests for memcheck.
89
90   \li enable_model-checking: Enable the model checking when set to true.
91
92   \li enable_debug: If enable_debug is set to 'off' Simgrid compile flag has '-DNDEBUG' option.
93
94   \li enable_jedule: To enable jedule mode, which creates visualizations of task schedules with Simdag.
95
96   \li enable_latency_bound_tracking: Set to on if you want to be warned when communications are limited by round trip time.
97
98   \li enable_lib_static: Enable generated Simgrid and smpi static libraries.
99
100   \li enable_supernovae: Set to true make one file for each lib and compile with those generated files.
101
102   \li enable_msg_deprecated: Simgrid is compiled with msg deprecated functions.
103
104   \li enable_print_message: When set to true configuration print more debug output.
105
106   \li gtnets_path: Path to gtnets install directory (ex /usr)
107
108   \li ns3_path: Path to ns3 install directory (ex /usr)
109
110   \li CMAKE_INSTALL_PREFIX: Path where are installed lib/ doc/ and include/ directories (ex /usr/local)
111
112   \li pipol_user: specify your pipol username if you want to use the pipol-remote command.
113
114 \subsubsection install_cmakeoption3 Initialization
115
116 Those options are initialized the first time you launch "cmake ." without specified option.
117
118 \verbatim
119 enable_gtnets                   on
120 enable_lua                      on
121 enable_smpi                     on
122 enable_tracing                  on
123 enable_compile_optimizations    on
124 enable_debug                    on
125 enable_compile_warnings         off
126 enable_maintainer_mode          off
127 enable_coverage                 off
128 enable_memcheck                 off
129 enable_model-checking           off
130 enable_jedule                   off
131 enable_latency_bound_tracking   off
132 enable_lib_static               off
133 CMAKE_INSTALL_PREFIX            /usr/local
134 gtnets_path                     null
135 pipol_user                      null
136 \endverbatim
137
138 \subsubsection install_cmakeoption4 How to reset the cache of options
139
140 When options have been set they are keep into a cache file named "CMakeCache.txt". So if you want
141 reset values you just delete this file located to the project directory.
142
143 \subsection install_cmakecompilation Cmake compilation
144
145 \subsubsection install_cmakecompilation1 With command line.
146
147 On Unix or Mac platform:
148
149 \verbatim
150 cmake -D[name]=[value] ... ./
151 make
152 \endverbatim
153
154 On Windows platform:
155
156 \verbatim
157 cmake -G"MinGW Makefiles" -D[name]=[value] ... ./
158 mingw32-make
159 \endverbatim
160
161 \subsubsection install_cmakecompilation2 With ccmake tool.
162
163 \verbatim
164 "ccmake ./"
165 \endverbatim
166 Then follow instructions.
167
168 \subsubsection install_cmakecompilation2bis Build out of source.
169
170 As cmake generate many files used for compilation, we recommend to make a build directory.
171 For examples you can make:
172
173 \verbatim
174 "navarrop@caraja:~/Developments$ cd simgrid/"
175 "navarrop@caraja:~/Developments/simgrid$ mkdir build_directory"
176 "navarrop@caraja:~/Developments/simgrid$ cd build_directory/"
177 "navarrop@caraja:~/Developments/simgrid/build_directory$ cmake ../"
178 "navarrop@caraja:~/Developments/simgrid/build_directory$ make"
179 \endverbatim
180
181 Or completely out of sources:
182
183 \verbatim
184 "navarrop@caraja:~/Developments$ mkdir build_dir"
185 "navarrop@caraja:~/Developments$ cd build_dir/"
186 "navarrop@caraja:~/Developments/build_dir$ cmake ../simgrid/"
187 "navarrop@caraja:~/Developments/build_dir$ make"
188 \endverbatim
189
190 Those two kinds of compilation allow to delete files created by compilation more easily.
191
192 \subsubsection install_cmakecompilation3 Resume of command line
193
194  \li CMake
195 \verbatim
196 cmake <path>                    configure the project for Unix and Mac
197 cmake -G"MinGW Makefiles" <path>        configure the project for Windows
198 make                            build all targets for Unix and Mac
199 ming32-make                             build all targets for windows
200 (g)make VERBOSE=1               build all targets and print build command lines
201 make check                      test all targets and summarize
202 make dist                       make the distrib
203 make distcheck                  check the dist (make + make dist + make check)
204 (g)make install                 install the project (doc/ bin/ lib/ include/)
205 (g)make uninstall               uninstall the project (doc/ bin/ lib/ include/)
206 (g)make clean                   clean all targets
207 make simgrid_documentation      Create simgrid documentation
208 \endverbatim
209
210 When the project have been successfully compiling and build you can make tests.
211
212  \li CTest
213 \verbatim
214 ctest                   launch only tests
215 ctest -D Continuous
216 ctest -D Continuous(Start|Update|Configure|Build)
217 ctest -D Continuous(Test|Coverage|MemCheck|Submit)
218 ctest -D Experimental
219 ctest -D Experimental(Start|Update|Configure|Build)
220 ctest -D Experimental(Test|Coverage|MemCheck|Submit)
221 ctest -D Nightly
222 ctest -D Nightly(Start|Update|Configure|Build)
223 ctest -D Nightly(Test|Coverage|MemCheck|Submit)
224 ctest -D NightlyMemoryCheck
225 \endverbatim
226
227 If you want to test before make a commit you can simply make "ctest -D Experimental" and then you can visualize results submitted into Cdash. <a href="http://cdash.inria.fr/CDash/index.php?project=Simgrid">(Go to Cdash site)</a>.
228
229 \subsection install_cmakeinstall How to install with cmake?
230
231 \subsubsection install_cmakeinstall1 From Git.
232
233 \verbatim
234 git clone git://scm.gforge.inria.fr/simgrid/simgrid.git simgrid
235 cd simgrid
236 cmake -Denable_maintainer_mode=on -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./
237 make
238 make install
239 \endverbatim
240
241 \subsubsection install_cmakeinstall2 From a distrib
242
243 \verbatim
244 wget https://gforge.inria.fr/frs/download.php/28674/simgrid-3.6.1.tar.gz
245 tar xf simgrid-3.6.1.tar.gz
246 cd simgrid-3.6.1
247 cmake -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./
248 make
249 make install
250 \endverbatim
251
252 \section install_Win Installing the SimGrid framework on Windows
253
254 \subsection install_Win_install Installing SimGrid with the automatic installer
255
256 Before start the installation, you need to be sure to have the following dependencies:
257   \li cmake 2.8 <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
258   \li MinGW <a href="http://sourceforge.net/projects/mingw/files/MinGW/">(download page)</a>
259   \li perl <a href="http://www.activestate.com/activeperl/downloads">(download page)</a>
260   \li git <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">(download page)</a>
261
262 Then download the package <a href="https://gforge.inria.fr/frs/?group_id=12">SimGrid Installer</a>,
263 execute it and follow instructions.
264
265 \htmlonly
266 <a href="win_install_01.png" border=0><img src="win_install_01.png" border=0></a>
267 \endhtmlonly
268
269 Step 1: Accept the license.
270
271 \htmlonly
272 <a href="win_install_02.png" border=0><img src="win_install_02.png" border=0></a>
273 \endhtmlonly
274
275 Step 2: Select packets to install.
276
277 \htmlonly
278 <a href="win_install_03.png" border=0><img src="win_install_03.png" border=0></a>
279 \endhtmlonly
280
281 Step 3: Choice where to install packets previously selected. Please don't use spaces in path.
282
283 \htmlonly
284 <a href="win_install_04.png" border=0><img src="win_install_04.png" border=0></a>
285 \endhtmlonly
286
287 Step 4: Add CLASSPATH to environment variables.
288
289 \htmlonly
290 <a href="win_install_05.png" border=0><img src="win_install_05.png" border=0></a>
291 \endhtmlonly
292
293 Step 5: Add PATH to environment variables.
294
295 \htmlonly
296 <a href="win_install_06.png" border=0><img src="win_install_06.png" border=0></a>
297 \endhtmlonly
298
299 Step 6: Restart your computer to take in consideration environment variables.
300
301 \subsection install_Win_compile1 Compile a project "HelloWorld"
302
303 In the SimGrid install directory you should have an HelloWorld project to explain you how to start
304 compiling a source file. There are:
305 \verbatim
306 - HelloWorld.c          The example source file.
307 - CMakeLists.txt        It allows to configure the project.
308 - FindPCRE.cmake        This finds and links to the pcre library (Normally included
309                         into Simgrid directory "GnuWin32").
310 - README                This explaination.
311 \endverbatim
312
313 Now let's compile this example:
314 \li Run windows shell "cmd".
315 \li Open HelloWorld Directory ('cd' command line).
316 \li Create a build directory and change directory. (optional)
317 \li Type 'cmake -G"MinGW Makefiles" \<path_to_HelloWorld_project\>'
318 \li Run mingw32-make
319 \li You should obtain a runnable example ("HelloWorld.exe").
320
321 For compiling your own code you can simply copy the HelloWorld project and rename source name. It will
322 create a target with the same name of the source.
323
324 \subsection install_Win_compile2 How to add and compile a new example
325
326 \li Put your source file into the helloWord directory.
327 \li Edit CMakeLists.txt by removing the Find Targets section and add those two lines into this section
328 \verbatim
329 ################
330 # FIND TARGETS #
331 ################
332 #It creates a target called 'TARGET_NAME.exe' with the sources 'SOURCES'
333 add_executable(TARGET_NAME SOURCES)
334 #Links TARGET_NAME with simgrid and pcre
335 target_link_libraries(TARGET_NAME simgrid pcre)
336 \endverbatim
337 \li To initialize and build your project, you'll need to run
338 \verbatim
339 cmake -G"MinGW Makefiles" \<path_to_HelloWorld_project\>
340 \endverbatim
341 \li Run "mingw32-make"
342 \li You should obtain "TARGET_NAME.exe".
343
344 \subsection install_Win_ruby Setup a virtualbox to use SimGrid-Ruby on windows
345
346 Allan Espinosa made these set of Vagrant rules available so that you
347 can use the SimGrid Ruby bindings in a virtual machine using
348 VirtualBox. Thanks to him for that. You can find his project here:
349 https://github.com/aespinosa/simgrid-vagrant
350
351 \section install_mac Installing the SimGrid framework on Mac OS X
352
353 The Mac OS X system is part of the UNIX family, but it exhibits some
354 specificities that complicate a bit the build of SimGrid. Current
355 versions of SimGrid (3.7.x) can only be build with the GCC Compiler,
356 but recent OS X version provide only an ancient version of that tool
357 in the hope to see the users switch to the LLVM compiler family. The
358 problem is that SimGrid uses internal libraries of GCC, for stack
359 manipulation for example. We are working on removing this dependency
360 onto gcc to ease the build process, but this is still ongoing.
361
362 For the time being, you need to get a recent version of GCC on your
363 system to build SimGrid. Version 3.7.1  was successfully built on Mac
364 Lion 10.7.4 using a GCC compiler retrieved from macport. The package
365 used were gcc47, and the binary in the package were gcc-mp-4.7.
366
367 \section install_setting_MSG Setting up your own MSG code
368
369 Do not build your simulator by modifying the SimGrid examples.  Go
370 outside the SimGrid source tree and create your own working directory
371 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
372
373 Suppose your simulation has the following structure (remember it is
374 just an example to illustrate a possible way to compile everything;
375 feel free to organize it as you want).
376
377 \li <tt>sched.h</tt>: a description of the core of the
378     scheduler (i.e. which functions are can be used by the
379     agents). For example we could find the following functions
380     (master, forwarder, slave).
381 \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
382     implementing the core of the scheduler. Most of these
383     functions use the MSG functions defined in section \ref
384     msg_task_usage.
385 \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
386     the MSG initialization (MSG_init()), the platform
387     creation (e.g. with MSG_create_environment()), the
388     deployment phase (e.g. with MSG_function_register() and
389     MSG_launch_application()) and the call to MSG_main()).
390
391 To compile such a program, we suggest to use the following
392 Makefile. It is a generic Makefile that we have used many times with
393 our students when we teach the C language.
394
395 \verbatim
396 all: masterslave
397 masterslave: masterslave.o sched.o
398
399 INSTALL_PATH = $$HOME
400 CC = gcc
401 PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
402                                 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
403                                 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
404                                 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
405                                 -Wpointer-arith -Wwrite-strings -finline-functions
406 REASONABLY_CAREFUL_DUDE =       -Wall
407 NO_PRAYER_FOR_THE_WICKED =      -w -O2
408 WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
409 CFLAGS = -g $(WARNINGS)
410
411 INCLUDES = -I$(INSTALL_PATH)/include
412 DEFS = -L$(INSTALL_PATH)/lib/
413 LDADD = -lm -lsimgrid
414 LIBS =
415
416 %: %.o
417         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@
418
419 %.o: %.c
420         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
421
422 clean:
423         rm -f $(BIN_FILES) *.o *~
424 .SUFFIXES:
425 .PHONY: clean
426
427 \endverbatim
428
429 The first two lines indicates what should be build when typing make
430 (<tt>masterslave</tt>) and of which files it is to be made of
431 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
432 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
433 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
434 the static version, remove the <tt>-lsimgrid</tt> and add a
435 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
436 after the <tt>LIBS = </tt>.
437
438 More generally, if you have never written a Makefile by yourself, type
439 in a terminal: <tt>info make</tt> and read the introduction. The
440 previous example should be enough for a first try but you may want to
441 perform some more complex compilations...
442
443
444
445 */