Logo AND Algorithmique Numérique Distribuée

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