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 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 54 | - Ubuntu |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 55 | |
| 56 | In a terminal, enter:: |
| 57 | |
| 58 | sudo apt-get install build-essential |
Alexander Afanasyev | 0151579 | 2014-12-16 14:20:01 -0800 | [diff] [blame] | 59 | sudo apt-get install libsqlite3-dev libcrypto++-dev |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 60 | |
| 61 | # For Ubuntu 12.04 |
| 62 | sudo apt-get install libboost1.48-all-dev |
| 63 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 64 | # For all other Ubuntu versions |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 65 | sudo apt-get install libboost-all-dev |
| 66 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 67 | - Fedora |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 68 | |
| 69 | In a terminal, enter:: |
| 70 | |
| 71 | sudo yum install gcc-g++ git |
Alexander Afanasyev | 0151579 | 2014-12-16 14:20:01 -0800 | [diff] [blame] | 72 | sudo yum install sqlite-devel cryptopp-devel boost-devel |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 73 | |
| 74 | Optional: |
| 75 | ~~~~~~~~~ |
| 76 | |
| 77 | To build tutorials, manpages, and API documentation the following |
| 78 | dependencies need to be installed: |
| 79 | |
| 80 | - ``doxygen`` |
| 81 | - ``graphviz`` |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 82 | - ``python-sphinx`` and sphinx extensions ``sphinxcontrib-doxylink``, |
| 83 | ``sphinxcontrib-googleanalytics`` |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 84 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 85 | The following lists steps for common platforms to install these prerequisites: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 86 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 87 | - On OS X with MacPorts:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 88 | |
| 89 | sudo port install doxygen graphviz py27-sphinx sphinx_select |
| 90 | sudo port select sphinx py27-sphinx |
| 91 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 92 | # 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 Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 97 | - On Ubuntu:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 98 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 99 | sudo apt-get install doxygen graphviz python-sphinx python-pip |
| 100 | sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 101 | |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 102 | - On Fedora:: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 103 | |
Alexander Afanasyev | 5946ed1 | 2015-01-19 23:41:39 -0800 | [diff] [blame^] | 104 | sudo yum install doxygen graphviz python-sphinx |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 105 | sudo pip install sphinxcontrib-doxylink sphinxcontrib-googleanalytics |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 106 | |
| 107 | Build |
| 108 | ----- |
| 109 | |
| 110 | (These are instructions to build ndn-cxx. To do development of ndn-cxx |
| 111 | code and update the build system, see Development.) |
| 112 | |
| 113 | To 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 | |
| 121 | This 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 | |
| 139 | If configured with tests: ``./waf configure --with-tests``), the above |
| 140 | commands will also produce: |
| 141 | |
| 142 | - ``build/unit-tests``: A unit test binary for the library |
| 143 | |
Junxiao Shi | e04bd83 | 2014-11-29 23:02:38 -0700 | [diff] [blame] | 144 | 1.5GB available memory per CPU core is necessary for efficient compilation. |
| 145 | On a multi-core machine with less than 1.5GB available memory per CPU core, |
| 146 | limit the objects being compiled in parallel with ``./waf -jN`` where N is the amount |
| 147 | of available memory divided by 1.5GB (eg. ``./waf -j1`` for 1.5GB memory), |
| 148 | which could usually avoid memory thrashing and result in faster compilation. |
| 149 | |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 150 | Build with examples |
| 151 | ------------------- |
| 152 | |
| 153 | By 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 | |
| 161 | To 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 | |
| 174 | If you want to test out a sample application, just create a ``.cpp`` file in ``examples/`` |
| 175 | folder 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 Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 184 | Debug symbols |
| 185 | ~~~~~~~~~~~~~ |
| 186 | |
| 187 | The default compiler flags enable debug symbols to be included in binaries (i.e., ``-g`` |
| 188 | flag for ``./waf configure`` and ``-g3`` for ``./waf configure --debug``). This |
| 189 | potentially allows more meaningful debugging information if your application crashes. |
| 190 | |
| 191 | If 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 Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 199 | Documentation |
| 200 | ------------- |
| 201 | |
| 202 | ndn-cxx tutorials and API documentation can be built using the following |
| 203 | commands: |
| 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 | |
| 216 | Manpages are automatically created and installed during the normal build |
| 217 | process (e.g., during ``./waf`` and ``./waf install``), if |
| 218 | ``python-sphinx`` module is detected during ``./waf configure`` stage. |
| 219 | By default, manpages are installed into ``${PREFIX}/share/man`` (where |
| 220 | default value for ``PREFIX`` is ``/usr/local``). This location can be |
| 221 | changed during ``./waf configure`` stage using ``--prefix``, |
| 222 | ``--datarootdir``, or ``--mandir`` options. |
| 223 | |
| 224 | For more details, refer to ``./waf --help``. |
| 225 | |
| 226 | Development Build |
| 227 | ----------------- |
| 228 | |
| 229 | The 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 | |
| 237 | In the development build all compiler optimizations are disabled by |
| 238 | default and all warnings are treated as error. The default behavior can |
| 239 | be overridden by setting ``CXXFLAGS`` environment variable before |
| 240 | running ``./waf configure``: |
| 241 | |
| 242 | :: |
| 243 | |
| 244 | CXXFLAGS="-O1 -g3" ./waf configure --debug --with-tests |
| 245 | ... |
Alexander Afanasyev | 5946ed1 | 2015-01-19 23:41:39 -0800 | [diff] [blame^] | 246 | |
| 247 | Customize Compiler |
| 248 | ------------------ |
| 249 | |
| 250 | To customize compiler, set ``CXX`` environment variable to point to compiler binary and, in |
| 251 | some case, specify type of the compiler using ``--check-cxx-compiler``. For example, when |
| 252 | using clang compiler on Linux system, use the following: |
| 253 | |
| 254 | :: |
| 255 | |
| 256 | CXX=clang++ ./waf configure --check-cxx-compiler=clang++ |