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