SimGrid  3.7
Scalable simulation of distributed systems
Installing Simgrid

Installing the SimGrid library

Some generalitty

What is Cmake?

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 here.

Why cmake?

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.

What cmake need?

CMake needs some prerequists like :

For Unix and MacOS:

For Windows :

Liste of options

"cmake -D[name]=[value] ... ./"

[name] 	enable_gtnets		[value] ON/OFF or TRUE/FALSE or 1/0
	enable_ns3			ON/OFF or TRUE/FALSE or 1/0
	enable_lua			ON/OFF or TRUE/FALSE or 1/0
	enable_compile_optimizations	ON/OFF or TRUE/FALSE or 1/0
	enable_compile_warnings		ON/OFF or TRUE/FALSE or 1/0
	enable_smpi			ON/OFF or TRUE/FALSE or 1/0
	enable_maintainer_mode		ON/OFF or TRUE/FALSE or 1/0
	enable_tracing 			ON/OFF or TRUE/FALSE or 1/0
	enable_coverage 		ON/OFF or TRUE/FALSE or 1/0
	enable_memcheck 		ON/OFF or TRUE/FALSE or 1/0
	enable_model-checking		ON/OFF or TRUE/FALSE or 1/0
	enable_debug			ON/OFF or TRUE/FALSE or 1/0
	enable_jedule 	 		ON/OFF or TRUE/FALSE or 1/0
	enable_latency_bound_tracking 	ON/OFF or TRUE/FALSE or 1/0
	enable_lib_static		ON/OFF or TRUE/FALSE or 1/0
	enable_supernovae       	ON/OFF or TRUE/FALSE or 1/0
	enable_msg_deprecated   	ON/OFF or TRUE/FALSE or 1/0                                                                                                                                                                                                                                                                               
	enable_print_message    	ON/OFF or TRUE/FALSE or 1/0 
	custom_flags 			<flags>
	gtnets_path			<path_to_gtnets_directory>
	ns3_path			<path_to_ns3_directory>
	CMAKE_INSTALL_PREFIX		<path_to_install_directory>
	CMAKE_C_COMPILER		<path_to_compiler>
	CMAKE_CXX_COMPILER		<path_to_compiler>
	pipol_user			<pipol_username>

Options explaination

Initialisation

Those options are initialized the first time you launch "cmake ." whithout specified option.

enable_gtnets			on
enable_lua			on
enable_smpi			on
enable_tracing			on
enable_compile_optimizations	on
enable_debug			on
enable_compile_warnings		off
enable_maintainer_mode		off
enable_coverage 		off
enable_memcheck 		off
enable_model-checking		off
enable_jedule 	 		off
enable_latency_bound_tracking 	off 
enable_lib_static		off
CMAKE_INSTALL_PREFIX		/usr/local
custom_flags			null
gtnets_path			null
pipol_user			null

Option's cache and how to reset?

When options have been set they are keep into a cache file named "CMakeCache.txt". So if you want reset values you just delete this file located to the project directory.

Cmake compilation

With command line.

On Unix or Mac platform:

cmake -D[name]=[value] ... ./
make

On Windows platform:

cmake -G"MinGW Makefiles" -D[name]=[value] ... ./
mingw32-make

With ccmake tool.

"ccmake ./"

Then follow instructions.

Build out of source.

As cmake generate many files used for compilation, we recommand to make a build directory. For examples you can make :

"navarrop@caraja:~/Developments$ cd simgrid/"
"navarrop@caraja:~/Developments/simgrid$ mkdir build_directory"
"navarrop@caraja:~/Developments/simgrid$ cd build_directory/"
"navarrop@caraja:~/Developments/simgrid/build_directory$ cmake ../"
"navarrop@caraja:~/Developments/simgrid/build_directory$ make"

Or complety out of sources :

"navarrop@caraja:~/Developments$ mkdir build_dir"
"navarrop@caraja:~/Developments$ cd build_dir/"
"navarrop@caraja:~/Developments/build_dir$ cmake ../simgrid/"
"navarrop@caraja:~/Developments/build_dir$ make"

Those two kind of compilation permit to delete files created by compilation easier.

Resume of command line

When the project have been succesfully compiling and build you can make tests.

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. (Go to Cdash site).

How to install with cmake?

From Git.

git clone git://scm.gforge.inria.fr/simgrid/simgrid.git simgrid
cd simgrid
cmake -Denable_maintainer_mode=on -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./
make 
make install

From a distrib

wget https://gforge.inria.fr/frs/download.php/28674/simgrid-3.6.1.tar.gz
tar xf simgrid-3.6.1.tar.gz
cd simgrid-3.6.1
cmake -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./
make
make install

How to modified sources files for developers

Add an executable or examples.

If you want make an executable you have to create a CMakeList.txt to the src directory. You must specified where to create the executable, source list, dependencies and the name of the binary.

cmake_minimum_required(VERSION 2.6)

set(EXECUTABLE_OUTPUT_PATH "./")			
set(LIBRARY_OUTPUT_PATH "${CMAKE_HOME_DIRECTORY}/lib")

add_executable(get_sender get_sender.c)					#add_executable(<name_of_target> <src list>)

### Add definitions for compile
target_link_libraries(get_sender simgrid m pthread) 	#target_link_libraries(<name_of_targe> <dependencies>)

Then you have to modified <project/directory>/buildtools/Cmake/MakeExeLib.cmake and add this line :

add_subdirectory(${CMAKE_HOME_DIRECTORY}/<path_where_is_CMakeList.txt>)

Delete/add sources to lib.

If you want modified, add or delete source files from a library you have to edit <project/directory>/buildtools/Cmake/DefinePackages.cmake

set(JMSG_JAVA_SRC
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/MsgException.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/JniException.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/NativeException.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/HostNotFoundException.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/ProcessNotFoundException.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Msg.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Process.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Host.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Task.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/MsgNative.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/ApplicationHandler.java
	${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Sem.java
)

Installing the SimGrid framework on Windows

Installing SimGrid with the automatic installer

Before start the installation, you need to be sure to have the following dependencies:

Then download the package SimGrid Installer, execute it and follow instructions.

Step 1: Accept the license.

Step 2: Select packets to install.

Step 3: Choice where to install packets previously selected. Please don't use spaces in path.

Step 4: Add CLASSPATH to environment variables.

Step 5: Add PATH to environment variables.

Step 6: Restart your computer to take in consideration environment variables.

Compile a project "HelloWorld"

In the SimGrid install directroy you should have an HelloWorld project to explain you how to start compiling a source file. There are:

- HelloWorld.c		The example source file.
- CMakeLists.txt	It allows to configure the project.
- FindPCRE.cmake	This finds and links to the pcre library (Normally included into Simgrid directory "GnuWin32").
- README 		This explaination.

Now let's compil this example:

For compiling your own code you can simply copy the HelloWorld project and rename source name. It will create a target with the same name of the source.

How to add and compile a new example

Setup a virtualbox to use SimGrid-Ruby on windows

Allan Espinosa made these set of Vagrant rules available so that you can use the SimGrid Ruby bindings in a virtual machine using VirtualBox. Thanks to him for that. You can find his project here: https://github.com/aespinosa/simgrid-vagrant

Setting up your own MSG code

Do not build your simulator by modifying the SimGrid examples. Go outside the SimGrid source tree and create your own working directory (say /home/joe/SimGrid/MyFirstScheduler/).

Suppose your simulation has the following structure (remember it is just an example to illustrate a possible way to compile everything; feel free to organize it as you want).

To compile such a program, we suggest to use the following Makefile. It is a generic Makefile that we have used many times with our students when we teach the C language.

all: masterslave 
masterslave: masterslave.o sched.o

INSTALL_PATH = $$HOME
CC = gcc
PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
				-Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
				-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
				-Wmissing-noreturn -Wredundant-decls -Wnested-externs \
				-Wpointer-arith -Wwrite-strings -finline-functions
REASONABLY_CAREFUL_DUDE =	-Wall
NO_PRAYER_FOR_THE_WICKED =	-w -O2 
WARNINGS = 			$(REASONABLY_CAREFUL_DUDE)
CFLAGS = -g $(WARNINGS)

INCLUDES = -I$(INSTALL_PATH)/include
DEFS = -L$(INSTALL_PATH)/lib/
LDADD = -lm -lsimgrid 
LIBS = 

%: %.o
	$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ 

%.o: %.c
	$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<

clean:
	rm -f $(BIN_FILES) *.o *~
.SUFFIXES:
.PHONY : clean

The first two lines indicates what should be build when typing make (masterslave) and of which files it is to be made of (masterslave.o and sched.o). This makefile assumes that you have set up correctly your LD_LIBRARY_PATH variable (look, there is a LDADD = -lm -lsimgrid). If you prefer using the static version, remove the -lsimgrid and add a /lib/libsimgrid.a on the next line, right after the LIBS = .

More generally, if you have never written a Makefile by yourself, type in a terminal : info make and read the introduction. The previous example should be enough for a first try but you may want to perform some more complex compilations...

Setting up your own GRAS code

If you use the GRAS interface instead of the MSG one, then previous section is not the better source of information. Instead, you should check the GRAS tutorial in general, and the Lesson 1: Setting up your own project in particular.


Back to the main Simgrid Documentation page The version of SimGrid documented here is v3.7.
Documentation of other versions can be found in their respective archive files (directory doc/html).
Generated by doxygen