blob: ceb4675a51c8e217d48e2b104c3cee87934f744a [file] [log] [blame]
Alexander Afanasyevabaab522014-04-30 20:42:11 -07001.. _Getting Started with ndn-cxx:
2
Alexander Afanasyevc5452c52014-04-29 17:21:51 -07003Getting started with ndn-cxx
4============================
5
6Supported platforms
7-------------------
8
9ndn-cxx uses continuous integration and has been tested on the following
10platforms:
11
12- Ubuntu 12.04 (64-bit and 32-bit)
13- Ubuntu 13.10 (64-bit and 32-bit)
14- OS X 10.8
15- OS X 10.9
16
17ndn-cxx is known to work on the following platforms, although they are not officially
18supported:
19
20- Ubuntu 14.04
21- Fedora >= 20
22- FreeBSD >= 10.0
23- Raspberry Pi
24
25Prerequisites
26-------------
27
28Required:
29~~~~~~~~~
30
31- ``python`` >= 2.6
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070032- ``libsqlite3``
33- ``libcrypto++``
34- ``pkg-config``
35- Boost libraries >= 1.48
36- OSX Security framework (on OSX platform only)
37
38Following are the detailed steps for each platform to install the compiler, all necessary
39development tools and libraries, and ndn-cxx prerequisites.
40
41- OS X
42
43 Install Xcode. In Xcode Preferences > Downloads, install "Command
44 Line Tools".
45
46 If using MacPorts, dependencies can be installed using the following
47 commands::
48
49 sudo port install pkgconfig boost sqlite3 libcryptopp
50
51- Ubuntu 12.04, Ubuntu 13.10
52
53 In a terminal, enter::
54
55 sudo apt-get install build-essential
Alexander Afanasyev01515792014-12-16 14:20:01 -080056 sudo apt-get install libsqlite3-dev libcrypto++-dev
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070057
58 # For Ubuntu 12.04
59 sudo apt-get install libboost1.48-all-dev
60
61 # For Ubuntu 13.10
62 sudo apt-get install libboost-all-dev
63
64- Fedora >=20
65
66 In a terminal, enter::
67
68 sudo yum install gcc-g++ git
Alexander Afanasyev01515792014-12-16 14:20:01 -080069 sudo yum install sqlite-devel cryptopp-devel boost-devel
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070070
71Optional:
72~~~~~~~~~
73
74To build tutorials, manpages, and API documentation the following
75dependencies need to be installed:
76
77- ``doxygen``
78- ``graphviz``
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -070079- ``python-sphinx`` and sphinx extensions ``sphinxcontrib-doxylink``,
80 ``sphinxcontrib-googleanalytics``
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070081
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -070082The following lists steps for common platforms to install these prerequisites:
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070083
84- On OS X 10.8 and 10.9 with MacPorts::
85
86 sudo port install doxygen graphviz py27-sphinx sphinx_select
87 sudo port select sphinx py27-sphinx
88
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -070089 # Install sphinx extensions
90 sudo port install py27-pip
91 sudo port select pip pip27
92 sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics
93
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070094- On Ubuntu >= 12.04::
95
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -070096 sudo apt-get install doxygen graphviz python-sphinx python-pip
97 sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070098
99- On Fedora >= 20::
100
101 sudp yum install doxygen graphviz python-sphinx
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -0700102 sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics
Alexander Afanasyevc5452c52014-04-29 17:21:51 -0700103
104Build
105-----
106
107(These are instructions to build ndn-cxx. To do development of ndn-cxx
108code and update the build system, see Development.)
109
110To build in a terminal, change directory to the ndn-cxx root. Enter:
111
112::
113
114 ./waf configure
115 ./waf
116 sudo ./waf install
117
118This builds and installs the following items:
119
120- ``<LIBPATH>/libndn-cxx.a``: static NDN C++ library
121- ``<LIBPATH>/pkgconfig/libndn-cxx.pc``: pkgconfig file storing all
122 neccessary flags to build against the library. For example, if
123 pkgconfig or pkgconf package is installed and ``PKG_CONFIG_PATH`` is
124 configured properly (or ``<LIBPATH>/pkgconfig`` is a default path),
125 ``pkgconfig --libs --clflags libndn-cxx`` will return all necessary
126 compile and link flags for the library.
127- ``<BINPATH>/tlvdump``: a simple tool to dump contents of
128 TLV-formatted data
129- ``<BINPATH>/ndncatchunks3``: a simplified equivalent to ndncatchunks2
130 in NDNx package
131- ``<BINPATH>/ndnputchunks3``: a simplified equivalent to ndnputchunks2
132 in NDNx package
133- ``<BINPATH>/ndnsec``: tool to manage NDN keys and certificates
134- ``<BINPATH>/ndnsec-*``: convenience scripts for ``ndnsec`` tools
135
136If configured with tests: ``./waf configure --with-tests``), the above
137commands will also produce:
138
139- ``build/unit-tests``: A unit test binary for the library
140
Junxiao Shie04bd832014-11-29 23:02:38 -07001411.5GB available memory per CPU core is necessary for efficient compilation.
142On a multi-core machine with less than 1.5GB available memory per CPU core,
143limit the objects being compiled in parallel with ``./waf -jN`` where N is the amount
144of available memory divided by 1.5GB (eg. ``./waf -j1`` for 1.5GB memory),
145which could usually avoid memory thrashing and result in faster compilation.
146
Alexander Afanasyevc8bcd452014-05-12 17:58:47 -0700147Build with examples
148-------------------
149
150By default, examples in ``examples/`` are not build. To enable them, use
151``--with-examples`` configure option:
152
153::
154
155 ./waf configure --with-examples
156 ./waf
157
158To run examples:
159
160::
161
162 # trivial producer app
163 ./build/examples/producer
164
165 # trivial consumer app
166 ./build/examples/consumer
167
168 # trivial consumer app with timers
169 ./build/examples/consumer-with-timer
170
171If you want to test out a sample application, just create a ``.cpp`` file in ``examples/``
172folder and it will be compiled on the next run on ``./waf``. For example:
173
174::
175
176 cp examples/consumer.cpp examples/my-new-consumer-app.cpp
177 ./waf
178 ./build/examples/my-new-consumer-app
179
180
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -0700181Debug symbols
182~~~~~~~~~~~~~
183
184The default compiler flags enable debug symbols to be included in binaries (i.e., ``-g``
185flag for ``./waf configure`` and ``-g3`` for ``./waf configure --debug``). This
186potentially allows more meaningful debugging information if your application crashes.
187
188If it is undesirable, default flags can be easily overridden:
189
190::
191
192 CXXFLAGS="-O2" ./waf configure --prefix=/usr --sysconfdir=/etc
193 ./waf
194 sudo ./waf install
195
Alexander Afanasyevc5452c52014-04-29 17:21:51 -0700196Documentation
197-------------
198
199ndn-cxx tutorials and API documentation can be built using the following
200commands:
201
202::
203
204 # Full set of documentation (tutorials + API) in build/docs
205 ./waf docs
206
207 # Only tutorials in `build/docs`
208 ./waf sphinx
209
210 # Only API docs in `build/docs/doxygen`
211 ./waf doxgyen
212
213Manpages are automatically created and installed during the normal build
214process (e.g., during ``./waf`` and ``./waf install``), if
215``python-sphinx`` module is detected during ``./waf configure`` stage.
216By default, manpages are installed into ``${PREFIX}/share/man`` (where
217default value for ``PREFIX`` is ``/usr/local``). This location can be
218changed during ``./waf configure`` stage using ``--prefix``,
219``--datarootdir``, or ``--mandir`` options.
220
221For more details, refer to ``./waf --help``.
222
223Development Build
224-----------------
225
226The following is the suggested configure commands for development build.
227
228::
229
230 ./waf configure --debug --with-tests
231 ./waf
232 sudo ./waf install
233
234In the development build all compiler optimizations are disabled by
235default and all warnings are treated as error. The default behavior can
236be overridden by setting ``CXXFLAGS`` environment variable before
237running ``./waf configure``:
238
239::
240
241 CXXFLAGS="-O1 -g3" ./waf configure --debug --with-tests
242 ...