Files
unison/doc/build.txt

117 lines
3.6 KiB
Plaintext
Raw Normal View History

2021-11-29 21:58:30 -03:00
The CMake build system is used to build ns-3. CMake is a
meta-build system (https://cmake.org/)
2007-07-16 21:41:19 -07:00
2008-09-11 08:45:00 -07:00
Note: We've added a wiki page with more complete build instructions
than the quick ones you find below:
2013-11-13 16:06:43 -05:00
http://www.nsnam.org/wiki/Installation
2008-09-11 08:45:00 -07:00
2021-11-29 21:58:30 -03:00
=== Installing CMake ===
2007-07-16 21:41:19 -07:00
2021-11-29 21:58:30 -03:00
To use CMake, you need to download it and install it. This can be done
via package managers available for your operating system, or directly
from the CMake page: https://cmake.org/download/.
2008-12-29 13:28:54 +00:00
2021-11-29 21:58:30 -03:00
CMake is a meta-build system that relies on an underlying build system.
This build system is referred to as Generators by CMake
(https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html),
and include Makefiles, Ninja, XCode, Eclipse CDT4 and others.
2008-12-29 13:28:54 +00:00
2021-11-29 21:58:30 -03:00
One of these must be installed for CMake to work.
2008-12-29 13:28:54 +00:00
2007-07-16 21:41:19 -07:00
2021-11-29 21:58:30 -03:00
=== Building with ns3 ===
2007-07-16 21:41:19 -07:00
2021-11-29 21:58:30 -03:00
To build ns-3 with the ns3 CMake wrapper type the commands from the top-level directory:
1. ./ns3 configure [options]
2. ./ns3 build
To see valid configure options, type ./ns3 --help. The most important
2007-07-16 21:41:19 -07:00
option is -d <debug level>. Valid debug levels (which are listed in
2021-11-29 21:58:30 -03:00
ns3 --help) are: "debug" or "optimized", with debug being default. It is
2007-07-16 21:41:19 -07:00
also possible to change the flags used for compilation with (e.g.):
2021-11-29 21:58:30 -03:00
CXXFLAGS="-O3" ./ns3 configure. By default, ns-3 is built as debug code,
2011-12-07 16:11:42 -08:00
with examples and tests disabled, and with python bindings enabled.
2007-07-16 21:41:19 -07:00
[ Note: Unlike some other build tools, to change the build target,
the option must be supplied during the configure stage rather than
2021-11-29 21:58:30 -03:00
the build stage (i.e., "./ns3 build -d optimized" will not work; instead, do
"./ns3 configure -d optimized; ./ns3 build" ]
2007-07-16 21:41:19 -07:00
2011-12-07 16:11:42 -08:00
The resulting executables and libraries are placed in build/.
2007-07-16 21:41:19 -07:00
2021-11-29 21:58:30 -03:00
Other ns3 usages include:
2007-07-16 21:41:19 -07:00
2021-11-29 21:58:30 -03:00
1. ./ns3 configure --enable-examples --enable-tests
2011-04-12 14:35:16 -07:00
Turn on examples and tests.
2007-07-16 21:41:19 -07:00
2021-11-29 21:58:30 -03:00
2. ./ns3 configure --disable-python
2011-12-07 16:11:42 -08:00
Disable python bindings.
2007-07-16 21:41:19 -07:00
2022-01-13 23:59:59 -03:00
3. ./ns3 docs doxygen
2011-12-07 16:11:42 -08:00
Run doxygen to generate documentation
2007-07-16 21:41:19 -07:00
2022-01-13 23:59:59 -03:00
4. ./ns3 run "program [args]"
2007-07-16 21:41:19 -07:00
Run a ns3 program, given its target name, with the given
2017-09-01 11:40:28 +03:00
arguments. This takes care of automatically modifying the
2007-07-16 21:41:19 -07:00
path for finding the ns3 dynamic libraries in the environment
before running the program. Note: the "program [args]" string is
parsed using POSIX shell rules.
2022-01-13 23:59:59 -03:00
4.1 ./ns3 run program-name --command-template "... %s ..."
2022-01-13 23:59:59 -03:00
Same as run, but uses a command template with %s replaced by the
actual program (whose name is given by run). This can be use to
run ns-3 programs with helper tools. For example, to run unit
tests with valgrind, use the command:
2022-01-13 23:59:59 -03:00
./ns3 run run-tests --command-template "valgrind %s"
2022-01-13 23:59:59 -03:00
5. ./ns3 shell
2007-07-16 21:41:19 -07:00
Starts a nested system shell with modified environment to run ns3 programs.
2021-11-29 21:58:30 -03:00
6. ./ns3 clean
2007-07-16 21:41:19 -07:00
Cleans out the entire build/ directory
=== Extending ns-3 ===
To add new modules:
1. Create the module directory under src;
2007-07-16 21:41:19 -07:00
2. Add the source files to it;
2021-11-29 21:58:30 -03:00
3. Add a 'CMakeLists.txt' describing it;
2011-12-07 16:11:42 -08:00
A convenience program to auto-generate the template of a new module can
be found in src/create-module.py.
2007-07-16 21:41:19 -07:00
2021-11-29 21:58:30 -03:00
A ns-3 module is created as a cpp/shlib object, like this:
set(name ns3-mymodule)
set(source_files
model/ns3-mymodule.cc
helper/ns3-mymodule-helper.cc
)
set(header_files
model/ns3-mymodule.h
helper/ns3-mymodule-helper.h
)
2007-07-16 21:41:19 -07:00
2021-11-29 21:58:30 -03:00
set(libraries_to_link
libcore # lib prefix + module name
)
2011-12-07 16:11:42 -08:00
2021-11-29 21:58:30 -03:00
set(test_sources
test/test-mymodule.cc
)
2007-07-16 21:41:19 -07:00
build_lib(
LIBNAME ${name}
SOURCE_FILES ${source_files}
HEADER_FILES ${header_files}
LIBRARIES_TO_LINK ${libraries_to_link}
TEST_SOURCES ${test_sources}
)
2007-07-16 21:41:19 -07:00