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 | |
| 12 | - Ubuntu 12.04 (64-bit and 32-bit) |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 13 | - Ubuntu 14.04 (64-bit and 32-bit) |
| 14 | - Ubuntu 14.10 (64-bit and 32-bit) |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 15 | - OS X 10.8 |
| 16 | - OS X 10.9 |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 17 | - OS X 10.10 |
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++`` |
| 37 | - ``pkg-config`` |
| 38 | - Boost libraries >= 1.48 |
| 39 | - OSX Security framework (on OSX platform only) |
| 40 | |
| 41 | Following are the detailed steps for each platform to install the compiler, all necessary |
| 42 | development 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 | |
Junxiao Shi | 190bee2 | 2015-02-14 19:21:36 -0700 | [diff] [blame] | 54 | .. note:: |
| 55 | |
| 56 | If a major OS X system upgrade is performed after installing dependencies with MacPorts, |
| 57 | remember to `reinstall all ports <https://trac.macports.org/wiki/Migration>`__. |
| 58 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 59 | - Ubuntu |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 60 | |
| 61 | In a terminal, enter:: |
| 62 | |
| 63 | sudo apt-get install build-essential |
Alexander Afanasyev | 0151579 | 2014-12-16 14:20:01 -0800 | [diff] [blame] | 64 | sudo apt-get install libsqlite3-dev libcrypto++-dev |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 65 | |
| 66 | # For Ubuntu 12.04 |
| 67 | sudo apt-get install libboost1.48-all-dev |
| 68 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 69 | # For all other Ubuntu versions |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 70 | sudo apt-get install libboost-all-dev |
| 71 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 72 | - Fedora |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 73 | |
| 74 | In a terminal, enter:: |
| 75 | |
| 76 | sudo yum install gcc-g++ git |
Alexander Afanasyev | 0151579 | 2014-12-16 14:20:01 -0800 | [diff] [blame] | 77 | sudo yum install sqlite-devel cryptopp-devel boost-devel |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 78 | |
| 79 | Optional: |
| 80 | ~~~~~~~~~ |
| 81 | |
| 82 | To build tutorials, manpages, and API documentation the following |
| 83 | dependencies need to be installed: |
| 84 | |
| 85 | - ``doxygen`` |
| 86 | - ``graphviz`` |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 87 | - ``python-sphinx`` and sphinx extensions ``sphinxcontrib-doxylink``, |
| 88 | ``sphinxcontrib-googleanalytics`` |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 89 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 90 | The following lists steps for common platforms to install these prerequisites: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 91 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 92 | - On OS X with MacPorts:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 93 | |
| 94 | sudo port install doxygen graphviz py27-sphinx sphinx_select |
| 95 | sudo port select sphinx py27-sphinx |
| 96 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 97 | # Install sphinx extensions |
| 98 | sudo port install py27-pip |
| 99 | sudo port select pip pip27 |
| 100 | sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics |
| 101 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 102 | - On Ubuntu:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 103 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 104 | sudo apt-get install doxygen graphviz python-sphinx python-pip |
| 105 | sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 106 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 107 | - On Fedora:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 108 | |
Alexander Afanasyev | 5946ed1 | 2015-01-19 23:41:39 -0800 | [diff] [blame] | 109 | sudo yum install doxygen graphviz python-sphinx |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 110 | sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 111 | |
| 112 | Build |
| 113 | ----- |
| 114 | |
| 115 | (These are instructions to build ndn-cxx. To do development of ndn-cxx |
| 116 | code and update the build system, see Development.) |
| 117 | |
| 118 | To build in a terminal, change directory to the ndn-cxx root. Enter: |
| 119 | |
| 120 | :: |
| 121 | |
| 122 | ./waf configure |
| 123 | ./waf |
| 124 | sudo ./waf install |
| 125 | |
| 126 | This builds and installs the following items: |
| 127 | |
| 128 | - ``<LIBPATH>/libndn-cxx.a``: static NDN C++ library |
| 129 | - ``<LIBPATH>/pkgconfig/libndn-cxx.pc``: pkgconfig file storing all |
| 130 | neccessary flags to build against the library. For example, if |
| 131 | pkgconfig or pkgconf package is installed and ``PKG_CONFIG_PATH`` is |
| 132 | configured properly (or ``<LIBPATH>/pkgconfig`` is a default path), |
| 133 | ``pkgconfig --libs --clflags libndn-cxx`` will return all necessary |
| 134 | compile and link flags for the library. |
| 135 | - ``<BINPATH>/tlvdump``: a simple tool to dump contents of |
| 136 | TLV-formatted data |
| 137 | - ``<BINPATH>/ndncatchunks3``: a simplified equivalent to ndncatchunks2 |
| 138 | in NDNx package |
| 139 | - ``<BINPATH>/ndnputchunks3``: a simplified equivalent to ndnputchunks2 |
| 140 | in NDNx package |
| 141 | - ``<BINPATH>/ndnsec``: tool to manage NDN keys and certificates |
| 142 | - ``<BINPATH>/ndnsec-*``: convenience scripts for ``ndnsec`` tools |
| 143 | |
| 144 | If configured with tests: ``./waf configure --with-tests``), the above |
| 145 | commands will also produce: |
| 146 | |
| 147 | - ``build/unit-tests``: A unit test binary for the library |
| 148 | |
Junxiao Shi | e04bd83 | 2014-11-29 23:02:38 -0700 | [diff] [blame] | 149 | 1.5GB available memory per CPU core is necessary for efficient compilation. |
| 150 | On a multi-core machine with less than 1.5GB available memory per CPU core, |
| 151 | limit the objects being compiled in parallel with ``./waf -jN`` where N is the amount |
| 152 | of available memory divided by 1.5GB (eg. ``./waf -j1`` for 1.5GB memory), |
| 153 | which could usually avoid memory thrashing and result in faster compilation. |
| 154 | |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 155 | Build with examples |
| 156 | ------------------- |
| 157 | |
| 158 | By default, examples in ``examples/`` are not build. To enable them, use |
| 159 | ``--with-examples`` configure option: |
| 160 | |
| 161 | :: |
| 162 | |
| 163 | ./waf configure --with-examples |
| 164 | ./waf |
| 165 | |
| 166 | To run examples: |
| 167 | |
| 168 | :: |
| 169 | |
| 170 | # trivial producer app |
| 171 | ./build/examples/producer |
| 172 | |
| 173 | # trivial consumer app |
| 174 | ./build/examples/consumer |
| 175 | |
| 176 | # trivial consumer app with timers |
| 177 | ./build/examples/consumer-with-timer |
| 178 | |
| 179 | If you want to test out a sample application, just create a ``.cpp`` file in ``examples/`` |
| 180 | folder and it will be compiled on the next run on ``./waf``. For example: |
| 181 | |
| 182 | :: |
| 183 | |
| 184 | cp examples/consumer.cpp examples/my-new-consumer-app.cpp |
| 185 | ./waf |
| 186 | ./build/examples/my-new-consumer-app |
| 187 | |
| 188 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 189 | Debug symbols |
| 190 | ~~~~~~~~~~~~~ |
| 191 | |
| 192 | The default compiler flags enable debug symbols to be included in binaries (i.e., ``-g`` |
| 193 | flag for ``./waf configure`` and ``-g3`` for ``./waf configure --debug``). This |
| 194 | potentially allows more meaningful debugging information if your application crashes. |
| 195 | |
| 196 | If it is undesirable, default flags can be easily overridden: |
| 197 | |
| 198 | :: |
| 199 | |
| 200 | CXXFLAGS="-O2" ./waf configure --prefix=/usr --sysconfdir=/etc |
| 201 | ./waf |
| 202 | sudo ./waf install |
| 203 | |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 204 | Documentation |
| 205 | ------------- |
| 206 | |
| 207 | ndn-cxx tutorials and API documentation can be built using the following |
| 208 | commands: |
| 209 | |
| 210 | :: |
| 211 | |
| 212 | # Full set of documentation (tutorials + API) in build/docs |
| 213 | ./waf docs |
| 214 | |
| 215 | # Only tutorials in `build/docs` |
| 216 | ./waf sphinx |
| 217 | |
| 218 | # Only API docs in `build/docs/doxygen` |
| 219 | ./waf doxgyen |
| 220 | |
| 221 | Manpages are automatically created and installed during the normal build |
| 222 | process (e.g., during ``./waf`` and ``./waf install``), if |
| 223 | ``python-sphinx`` module is detected during ``./waf configure`` stage. |
| 224 | By default, manpages are installed into ``${PREFIX}/share/man`` (where |
| 225 | default value for ``PREFIX`` is ``/usr/local``). This location can be |
| 226 | changed during ``./waf configure`` stage using ``--prefix``, |
| 227 | ``--datarootdir``, or ``--mandir`` options. |
| 228 | |
| 229 | For more details, refer to ``./waf --help``. |
| 230 | |
| 231 | Development Build |
| 232 | ----------------- |
| 233 | |
| 234 | The following is the suggested configure commands for development build. |
| 235 | |
| 236 | :: |
| 237 | |
| 238 | ./waf configure --debug --with-tests |
| 239 | ./waf |
| 240 | sudo ./waf install |
| 241 | |
| 242 | In the development build all compiler optimizations are disabled by |
| 243 | default and all warnings are treated as error. The default behavior can |
| 244 | be overridden by setting ``CXXFLAGS`` environment variable before |
| 245 | running ``./waf configure``: |
| 246 | |
| 247 | :: |
| 248 | |
| 249 | CXXFLAGS="-O1 -g3" ./waf configure --debug --with-tests |
| 250 | ... |
Alexander Afanasyev | 5946ed1 | 2015-01-19 23:41:39 -0800 | [diff] [blame] | 251 | |
| 252 | Customize Compiler |
| 253 | ------------------ |
| 254 | |
| 255 | To customize compiler, set ``CXX`` environment variable to point to compiler binary and, in |
| 256 | some case, specify type of the compiler using ``--check-cxx-compiler``. For example, when |
| 257 | using clang compiler on Linux system, use the following: |
| 258 | |
| 259 | :: |
| 260 | |
| 261 | CXX=clang++ ./waf configure --check-cxx-compiler=clang++ |