Alexander Afanasyev | abaab52 | 2014-04-30 20:42:11 -0700 | [diff] [blame] | 1 | .. _Getting Started with ndn-cxx: |
| 2 | |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 3 | Getting started with ndn-cxx |
| 4 | ============================ |
| 5 | |
| 6 | Supported platforms |
| 7 | ------------------- |
| 8 | |
| 9 | ndn-cxx uses continuous integration and has been tested on the following |
| 10 | platforms: |
| 11 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 12 | - Ubuntu 14.04 (64-bit and 32-bit) |
Davide Pesavento | e11c8d8 | 2016-04-16 14:32:07 +0200 | [diff] [blame] | 13 | - Ubuntu 16.04 (64-bit and 32-bit) |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 14 | - OS X 10.8 |
| 15 | - OS X 10.9 |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 16 | - OS X 10.10 |
Davide Pesavento | e11c8d8 | 2016-04-16 14:32:07 +0200 | [diff] [blame] | 17 | - OS X 10.11 |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 18 | |
| 19 | ndn-cxx is known to work on the following platforms, although they are not officially |
| 20 | supported: |
| 21 | |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 22 | - Fedora >= 20 |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 23 | - CentOS >= 6.2 |
| 24 | - Gentoo Linux |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 25 | - FreeBSD >= 10.0 |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 26 | - Raspbian >= 3.12 |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 27 | |
| 28 | Prerequisites |
| 29 | ------------- |
| 30 | |
| 31 | Required: |
| 32 | ~~~~~~~~~ |
| 33 | |
| 34 | - ``python`` >= 2.6 |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 35 | - ``libsqlite3`` |
| 36 | - ``libcrypto++`` |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame^] | 37 | - OpenSSL version >= 1.0 |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 38 | - ``pkg-config`` |
Davide Pesavento | e6e6fde | 2016-04-16 14:44:45 +0200 | [diff] [blame] | 39 | - Boost libraries >= 1.54 |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 40 | - OSX Security framework (on OSX platform only) |
| 41 | |
| 42 | Following are the detailed steps for each platform to install the compiler, all necessary |
| 43 | development tools and libraries, and ndn-cxx prerequisites. |
| 44 | |
| 45 | - OS X |
| 46 | |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame^] | 47 | Install Xcode from AppStore or at least Command Line Tools (``xcode-select --install``) |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 48 | |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame^] | 49 | * When using MacPorts |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 50 | |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame^] | 51 | In a terminal, enter:: |
| 52 | |
| 53 | sudo port install pkgconfig boost sqlite3 libcryptopp openssl |
| 54 | |
| 55 | * When using Homebrew |
| 56 | |
| 57 | In a terminal, enter:: |
| 58 | |
| 59 | brew install boost pkg-config cryptopp openssl |
| 60 | brew link --force openssl |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 61 | |
Junxiao Shi | 190bee2 | 2015-02-14 19:21:36 -0700 | [diff] [blame] | 62 | .. note:: |
| 63 | |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame^] | 64 | If a major OS X system upgrade is performed after installing dependencies with |
| 65 | MacPorts or Homebrew, remember to reinstall all packages. |
Junxiao Shi | 190bee2 | 2015-02-14 19:21:36 -0700 | [diff] [blame] | 66 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 67 | - Ubuntu |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 68 | |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame^] | 69 | In a terminal, enter:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 70 | |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame^] | 71 | sudo apt-get install build-essential libcrypto++-dev libsqlite3-dev libboost-all-dev libssl-dev |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 72 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 73 | - Fedora |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 74 | |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame^] | 75 | In a terminal, enter:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 76 | |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame^] | 77 | sudo yum install gcc-g++ git |
| 78 | sudo yum install sqlite-devel cryptopp-devel boost-devel openssl-devel |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 79 | |
| 80 | Optional: |
| 81 | ~~~~~~~~~ |
| 82 | |
| 83 | To build tutorials, manpages, and API documentation the following |
| 84 | dependencies need to be installed: |
| 85 | |
| 86 | - ``doxygen`` |
| 87 | - ``graphviz`` |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 88 | - ``python-sphinx`` and sphinx extensions ``sphinxcontrib-doxylink``, |
| 89 | ``sphinxcontrib-googleanalytics`` |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 90 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 91 | The following lists steps for common platforms to install these prerequisites: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 92 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 93 | - On OS X with MacPorts:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 94 | |
| 95 | sudo port install doxygen graphviz py27-sphinx sphinx_select |
| 96 | sudo port select sphinx py27-sphinx |
| 97 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 98 | # Install sphinx extensions |
| 99 | sudo port install py27-pip |
| 100 | sudo port select pip pip27 |
| 101 | sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics |
| 102 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 103 | - On Ubuntu:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 104 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 105 | sudo apt-get install doxygen graphviz python-sphinx python-pip |
| 106 | sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 107 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 108 | - On Fedora:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 109 | |
Alexander Afanasyev | 5946ed1 | 2015-01-19 23:41:39 -0800 | [diff] [blame] | 110 | sudo yum install doxygen graphviz python-sphinx |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 111 | sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 112 | |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 113 | .. _build: |
| 114 | |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 115 | Build |
| 116 | ----- |
| 117 | |
| 118 | (These are instructions to build ndn-cxx. To do development of ndn-cxx |
| 119 | code and update the build system, see Development.) |
| 120 | |
| 121 | To build in a terminal, change directory to the ndn-cxx root. Enter: |
| 122 | |
| 123 | :: |
| 124 | |
| 125 | ./waf configure |
| 126 | ./waf |
| 127 | sudo ./waf install |
| 128 | |
Spyridon Mastorakis | 5ebfda6 | 2015-07-21 20:57:40 -0700 | [diff] [blame] | 129 | By default, only the shared version of ndn-cxx library is built. To build the static library, |
| 130 | use ``--enable-static`` option for ``./waf configure`` command. For example:: |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 131 | |
Spyridon Mastorakis | 5ebfda6 | 2015-07-21 20:57:40 -0700 | [diff] [blame] | 132 | ./waf configure --enable-static |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 133 | |
Spyridon Mastorakis | 5ebfda6 | 2015-07-21 20:57:40 -0700 | [diff] [blame] | 134 | To disable build of the shared library and build only the static library, use additional |
| 135 | ``--disable-shared`` option. Note that at least one version of the library needs to be |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 136 | enabled. |
| 137 | |
| 138 | :: |
| 139 | |
Spyridon Mastorakis | 5ebfda6 | 2015-07-21 20:57:40 -0700 | [diff] [blame] | 140 | ./waf configure --enable-static --disable-shared |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 141 | |
| 142 | |
Spyridon Mastorakis | 5ebfda6 | 2015-07-21 20:57:40 -0700 | [diff] [blame] | 143 | After the shared library is built and installed, some systems require additional actions. |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 144 | |
| 145 | - on Linux:: |
| 146 | |
| 147 | sudo ldconfig |
| 148 | |
| 149 | - on FreeBSD:: |
| 150 | |
| 151 | sudo ldconfig -m |
| 152 | |
| 153 | .. note:: |
| 154 | When library is installed in a non-standard path (in general: not in ``/usr/lib`` or |
| 155 | ``/usr/local/lib``; on some Linux distros including Fedora: not in ``/usr/lib``), |
| 156 | additional actions may be necessary. |
| 157 | |
| 158 | The installation path should be added to ``/etc/ld.so.conf`` (or in |
| 159 | ``/etc/ld.so.conf.d``) **before** running ``sudo ldconfig``. For example:: |
| 160 | |
| 161 | echo /usr/local/lib | sudo tee /etc/ld.so.conf.d/ndn-cxx.conf |
| 162 | |
| 163 | Alternatively, ``LD_LIBRARY_PATH`` environment variable should be set to the location of |
| 164 | the library:: |
| 165 | |
| 166 | export LD_LIBRARY_PATH=/usr/local/lib |
| 167 | |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 168 | This builds and installs the following items: |
| 169 | |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 170 | - ``<LIBPATH>/libndn-cxx.a``: static NDN C++ library (if enabled) |
| 171 | - ``<LIBPATH>/libndn-cxx.so``, ``<LIBPATH>/libndn-cxx.so.<VERSION>`` (on Linux), |
| 172 | ``<LIBPATH>/libndn-cxx.dylib``, ``<LIBPATH>/libndn-cxx.<VERSION>.dylib`` (on OS X): |
| 173 | shared NDN C++ library (if enabled) |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 174 | - ``<LIBPATH>/pkgconfig/libndn-cxx.pc``: pkgconfig file storing all |
| 175 | neccessary flags to build against the library. For example, if |
| 176 | pkgconfig or pkgconf package is installed and ``PKG_CONFIG_PATH`` is |
| 177 | configured properly (or ``<LIBPATH>/pkgconfig`` is a default path), |
| 178 | ``pkgconfig --libs --clflags libndn-cxx`` will return all necessary |
| 179 | compile and link flags for the library. |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 180 | - ``<BINPATH>/ndncatchunks3``: a simplified equivalent to ndncatchunks2 |
| 181 | in NDNx package |
| 182 | - ``<BINPATH>/ndnputchunks3``: a simplified equivalent to ndnputchunks2 |
| 183 | in NDNx package |
| 184 | - ``<BINPATH>/ndnsec``: tool to manage NDN keys and certificates |
| 185 | - ``<BINPATH>/ndnsec-*``: convenience scripts for ``ndnsec`` tools |
| 186 | |
| 187 | If configured with tests: ``./waf configure --with-tests``), the above |
| 188 | commands will also produce: |
| 189 | |
| 190 | - ``build/unit-tests``: A unit test binary for the library |
| 191 | |
Junxiao Shi | e04bd83 | 2014-11-29 23:02:38 -0700 | [diff] [blame] | 192 | 1.5GB available memory per CPU core is necessary for efficient compilation. |
| 193 | On a multi-core machine with less than 1.5GB available memory per CPU core, |
| 194 | limit the objects being compiled in parallel with ``./waf -jN`` where N is the amount |
| 195 | of available memory divided by 1.5GB (eg. ``./waf -j1`` for 1.5GB memory), |
| 196 | which could usually avoid memory thrashing and result in faster compilation. |
| 197 | |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 198 | Build with examples |
| 199 | ------------------- |
| 200 | |
| 201 | By default, examples in ``examples/`` are not build. To enable them, use |
| 202 | ``--with-examples`` configure option: |
| 203 | |
| 204 | :: |
| 205 | |
| 206 | ./waf configure --with-examples |
| 207 | ./waf |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 208 | sudo ./waf install |
| 209 | |
| 210 | :ref:`Additional step <build>`: |
| 211 | |
| 212 | - on Linux:: |
| 213 | |
| 214 | sudo ldconfig |
| 215 | |
| 216 | - on FreeBSD:: |
| 217 | |
| 218 | sudo ldconfig -m |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 219 | |
| 220 | To run examples: |
| 221 | |
| 222 | :: |
| 223 | |
| 224 | # trivial producer app |
| 225 | ./build/examples/producer |
| 226 | |
| 227 | # trivial consumer app |
| 228 | ./build/examples/consumer |
| 229 | |
| 230 | # trivial consumer app with timers |
| 231 | ./build/examples/consumer-with-timer |
| 232 | |
| 233 | If you want to test out a sample application, just create a ``.cpp`` file in ``examples/`` |
| 234 | folder and it will be compiled on the next run on ``./waf``. For example: |
| 235 | |
| 236 | :: |
| 237 | |
| 238 | cp examples/consumer.cpp examples/my-new-consumer-app.cpp |
| 239 | ./waf |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 240 | sudo ./waf install |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 241 | ./build/examples/my-new-consumer-app |
| 242 | |
| 243 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 244 | Debug symbols |
| 245 | ~~~~~~~~~~~~~ |
| 246 | |
| 247 | The default compiler flags enable debug symbols to be included in binaries (i.e., ``-g`` |
| 248 | flag for ``./waf configure`` and ``-g3`` for ``./waf configure --debug``). This |
| 249 | potentially allows more meaningful debugging information if your application crashes. |
| 250 | |
| 251 | If it is undesirable, default flags can be easily overridden: |
| 252 | |
| 253 | :: |
| 254 | |
| 255 | CXXFLAGS="-O2" ./waf configure --prefix=/usr --sysconfdir=/etc |
| 256 | ./waf |
| 257 | sudo ./waf install |
| 258 | |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 259 | :ref:`Additional step <build>`: |
| 260 | |
| 261 | - on Linux:: |
| 262 | |
| 263 | sudo ldconfig |
| 264 | |
| 265 | - on FreeBSD:: |
| 266 | |
| 267 | sudo ldconfig -m |
| 268 | |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 269 | Documentation |
| 270 | ------------- |
| 271 | |
| 272 | ndn-cxx tutorials and API documentation can be built using the following |
| 273 | commands: |
| 274 | |
| 275 | :: |
| 276 | |
| 277 | # Full set of documentation (tutorials + API) in build/docs |
| 278 | ./waf docs |
| 279 | |
| 280 | # Only tutorials in `build/docs` |
| 281 | ./waf sphinx |
| 282 | |
| 283 | # Only API docs in `build/docs/doxygen` |
| 284 | ./waf doxgyen |
| 285 | |
| 286 | Manpages are automatically created and installed during the normal build |
| 287 | process (e.g., during ``./waf`` and ``./waf install``), if |
| 288 | ``python-sphinx`` module is detected during ``./waf configure`` stage. |
| 289 | By default, manpages are installed into ``${PREFIX}/share/man`` (where |
| 290 | default value for ``PREFIX`` is ``/usr/local``). This location can be |
| 291 | changed during ``./waf configure`` stage using ``--prefix``, |
| 292 | ``--datarootdir``, or ``--mandir`` options. |
| 293 | |
| 294 | For more details, refer to ``./waf --help``. |
| 295 | |
| 296 | Development Build |
| 297 | ----------------- |
| 298 | |
| 299 | The following is the suggested configure commands for development build. |
| 300 | |
| 301 | :: |
| 302 | |
| 303 | ./waf configure --debug --with-tests |
| 304 | ./waf |
| 305 | sudo ./waf install |
| 306 | |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 307 | :ref:`Additional step <build>`: |
| 308 | |
| 309 | - on Linux:: |
| 310 | |
| 311 | sudo ldconfig |
| 312 | |
| 313 | - on FreeBSD:: |
| 314 | |
| 315 | sudo ldconfig -m |
| 316 | |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 317 | In the development build all compiler optimizations are disabled by |
| 318 | default and all warnings are treated as error. The default behavior can |
| 319 | be overridden by setting ``CXXFLAGS`` environment variable before |
| 320 | running ``./waf configure``: |
| 321 | |
| 322 | :: |
| 323 | |
| 324 | CXXFLAGS="-O1 -g3" ./waf configure --debug --with-tests |
| 325 | ... |
Alexander Afanasyev | 5946ed1 | 2015-01-19 23:41:39 -0800 | [diff] [blame] | 326 | |
| 327 | Customize Compiler |
| 328 | ------------------ |
| 329 | |
| 330 | To customize compiler, set ``CXX`` environment variable to point to compiler binary and, in |
| 331 | some case, specify type of the compiler using ``--check-cxx-compiler``. For example, when |
| 332 | using clang compiler on Linux system, use the following: |
| 333 | |
| 334 | :: |
| 335 | |
| 336 | CXX=clang++ ./waf configure --check-cxx-compiler=clang++ |