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