blob: d236c37a15d93841a274195a7d4016a0a7003fd0 [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)
Ivan Yeoba1a4a92015-01-11 00:45:57 -080013- Ubuntu 14.04 (64-bit and 32-bit)
14- Ubuntu 14.10 (64-bit and 32-bit)
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070015- OS X 10.8
16- OS X 10.9
Ivan Yeoba1a4a92015-01-11 00:45:57 -080017- OS X 10.10
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070018
19ndn-cxx is known to work on the following platforms, although they are not officially
20supported:
21
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070022- Fedora >= 20
Ivan Yeoba1a4a92015-01-11 00:45:57 -080023- CentOS >= 6.2
24- Gentoo Linux
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070025- FreeBSD >= 10.0
Ivan Yeoba1a4a92015-01-11 00:45:57 -080026- Raspbian >= 3.12
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070027
28Prerequisites
29-------------
30
31Required:
32~~~~~~~~~
33
34- ``python`` >= 2.6
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070035- ``libsqlite3``
36- ``libcrypto++``
37- ``pkg-config``
38- Boost libraries >= 1.48
39- OSX Security framework (on OSX platform only)
40
41Following are the detailed steps for each platform to install the compiler, all necessary
42development tools and libraries, and ndn-cxx prerequisites.
43
44- OS X
45
46 Install Xcode. In Xcode Preferences > Downloads, install "Command
47 Line Tools".
48
49 If using MacPorts, dependencies can be installed using the following
50 commands::
51
52 sudo port install pkgconfig boost sqlite3 libcryptopp
53
Ivan Yeoba1a4a92015-01-11 00:45:57 -080054- Ubuntu
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070055
56 In a terminal, enter::
57
58 sudo apt-get install build-essential
Alexander Afanasyev01515792014-12-16 14:20:01 -080059 sudo apt-get install libsqlite3-dev libcrypto++-dev
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070060
61 # For Ubuntu 12.04
62 sudo apt-get install libboost1.48-all-dev
63
Ivan Yeoba1a4a92015-01-11 00:45:57 -080064 # For all other Ubuntu versions
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070065 sudo apt-get install libboost-all-dev
66
Ivan Yeoba1a4a92015-01-11 00:45:57 -080067- Fedora
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070068
69 In a terminal, enter::
70
71 sudo yum install gcc-g++ git
Alexander Afanasyev01515792014-12-16 14:20:01 -080072 sudo yum install sqlite-devel cryptopp-devel boost-devel
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070073
74Optional:
75~~~~~~~~~
76
77To build tutorials, manpages, and API documentation the following
78dependencies need to be installed:
79
80- ``doxygen``
81- ``graphviz``
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -070082- ``python-sphinx`` and sphinx extensions ``sphinxcontrib-doxylink``,
83 ``sphinxcontrib-googleanalytics``
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070084
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -070085The following lists steps for common platforms to install these prerequisites:
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070086
Ivan Yeoba1a4a92015-01-11 00:45:57 -080087- On OS X with MacPorts::
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070088
89 sudo port install doxygen graphviz py27-sphinx sphinx_select
90 sudo port select sphinx py27-sphinx
91
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -070092 # Install sphinx extensions
93 sudo port install py27-pip
94 sudo port select pip pip27
95 sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics
96
Ivan Yeoba1a4a92015-01-11 00:45:57 -080097- On Ubuntu::
Alexander Afanasyevc5452c52014-04-29 17:21:51 -070098
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -070099 sudo apt-get install doxygen graphviz python-sphinx python-pip
100 sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics
Alexander Afanasyevc5452c52014-04-29 17:21:51 -0700101
Ivan Yeoba1a4a92015-01-11 00:45:57 -0800102- On Fedora::
Alexander Afanasyevc5452c52014-04-29 17:21:51 -0700103
104 sudp yum install doxygen graphviz python-sphinx
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -0700105 sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics
Alexander Afanasyevc5452c52014-04-29 17:21:51 -0700106
107Build
108-----
109
110(These are instructions to build ndn-cxx. To do development of ndn-cxx
111code and update the build system, see Development.)
112
113To build in a terminal, change directory to the ndn-cxx root. Enter:
114
115::
116
117 ./waf configure
118 ./waf
119 sudo ./waf install
120
121This builds and installs the following items:
122
123- ``<LIBPATH>/libndn-cxx.a``: static NDN C++ library
124- ``<LIBPATH>/pkgconfig/libndn-cxx.pc``: pkgconfig file storing all
125 neccessary flags to build against the library. For example, if
126 pkgconfig or pkgconf package is installed and ``PKG_CONFIG_PATH`` is
127 configured properly (or ``<LIBPATH>/pkgconfig`` is a default path),
128 ``pkgconfig --libs --clflags libndn-cxx`` will return all necessary
129 compile and link flags for the library.
130- ``<BINPATH>/tlvdump``: a simple tool to dump contents of
131 TLV-formatted data
132- ``<BINPATH>/ndncatchunks3``: a simplified equivalent to ndncatchunks2
133 in NDNx package
134- ``<BINPATH>/ndnputchunks3``: a simplified equivalent to ndnputchunks2
135 in NDNx package
136- ``<BINPATH>/ndnsec``: tool to manage NDN keys and certificates
137- ``<BINPATH>/ndnsec-*``: convenience scripts for ``ndnsec`` tools
138
139If configured with tests: ``./waf configure --with-tests``), the above
140commands will also produce:
141
142- ``build/unit-tests``: A unit test binary for the library
143
Junxiao Shie04bd832014-11-29 23:02:38 -07001441.5GB available memory per CPU core is necessary for efficient compilation.
145On a multi-core machine with less than 1.5GB available memory per CPU core,
146limit the objects being compiled in parallel with ``./waf -jN`` where N is the amount
147of available memory divided by 1.5GB (eg. ``./waf -j1`` for 1.5GB memory),
148which could usually avoid memory thrashing and result in faster compilation.
149
Alexander Afanasyevc8bcd452014-05-12 17:58:47 -0700150Build with examples
151-------------------
152
153By default, examples in ``examples/`` are not build. To enable them, use
154``--with-examples`` configure option:
155
156::
157
158 ./waf configure --with-examples
159 ./waf
160
161To run examples:
162
163::
164
165 # trivial producer app
166 ./build/examples/producer
167
168 # trivial consumer app
169 ./build/examples/consumer
170
171 # trivial consumer app with timers
172 ./build/examples/consumer-with-timer
173
174If you want to test out a sample application, just create a ``.cpp`` file in ``examples/``
175folder and it will be compiled on the next run on ``./waf``. For example:
176
177::
178
179 cp examples/consumer.cpp examples/my-new-consumer-app.cpp
180 ./waf
181 ./build/examples/my-new-consumer-app
182
183
Alexander Afanasyev9b0e1142014-05-08 00:17:34 -0700184Debug symbols
185~~~~~~~~~~~~~
186
187The default compiler flags enable debug symbols to be included in binaries (i.e., ``-g``
188flag for ``./waf configure`` and ``-g3`` for ``./waf configure --debug``). This
189potentially allows more meaningful debugging information if your application crashes.
190
191If it is undesirable, default flags can be easily overridden:
192
193::
194
195 CXXFLAGS="-O2" ./waf configure --prefix=/usr --sysconfdir=/etc
196 ./waf
197 sudo ./waf install
198
Alexander Afanasyevc5452c52014-04-29 17:21:51 -0700199Documentation
200-------------
201
202ndn-cxx tutorials and API documentation can be built using the following
203commands:
204
205::
206
207 # Full set of documentation (tutorials + API) in build/docs
208 ./waf docs
209
210 # Only tutorials in `build/docs`
211 ./waf sphinx
212
213 # Only API docs in `build/docs/doxygen`
214 ./waf doxgyen
215
216Manpages are automatically created and installed during the normal build
217process (e.g., during ``./waf`` and ``./waf install``), if
218``python-sphinx`` module is detected during ``./waf configure`` stage.
219By default, manpages are installed into ``${PREFIX}/share/man`` (where
220default value for ``PREFIX`` is ``/usr/local``). This location can be
221changed during ``./waf configure`` stage using ``--prefix``,
222``--datarootdir``, or ``--mandir`` options.
223
224For more details, refer to ``./waf --help``.
225
226Development Build
227-----------------
228
229The following is the suggested configure commands for development build.
230
231::
232
233 ./waf configure --debug --with-tests
234 ./waf
235 sudo ./waf install
236
237In the development build all compiler optimizations are disabled by
238default and all warnings are treated as error. The default behavior can
239be overridden by setting ``CXXFLAGS`` environment variable before
240running ``./waf configure``:
241
242::
243
244 CXXFLAGS="-O1 -g3" ./waf configure --debug --with-tests
245 ...