Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 1 | Getting started with ndn-cxx |
| 2 | ============================ |
| 3 | |
| 4 | Supported platforms |
| 5 | ------------------- |
| 6 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 7 | ndn-cxx is built against a continuous integration system and has been tested on the |
| 8 | following platforms: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 9 | |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 10 | - Ubuntu 18.04 (amd64, armhf, i386) |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 11 | - Ubuntu 20.04 (amd64) |
Davide Pesavento | 3ffae26 | 2021-08-27 18:48:22 -0400 | [diff] [blame] | 12 | - Ubuntu 21.04 (amd64) |
Alexander Afanasyev | cf8ffd4 | 2019-12-29 17:58:53 -0800 | [diff] [blame] | 13 | - macOS 10.15 |
Davide Pesavento | 83f8d16 | 2021-09-26 21:58:36 -0400 | [diff] [blame] | 14 | - macOS 11 (Intel only) |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 15 | - CentOS 8 |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 16 | |
| 17 | ndn-cxx is known to work on the following platforms, although they are not officially |
| 18 | supported: |
| 19 | |
Davide Pesavento | 3ffae26 | 2021-08-27 18:48:22 -0400 | [diff] [blame] | 20 | - Alpine >= 3.12 |
| 21 | - Debian >= 10 |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 22 | - Fedora >= 29 |
Ivan Yeo | ba1a4a9 | 2015-01-11 00:45:57 -0800 | [diff] [blame] | 23 | - Gentoo Linux |
Davide Pesavento | 3ffae26 | 2021-08-27 18:48:22 -0400 | [diff] [blame] | 24 | - Raspberry Pi OS (formerly Raspbian) >= 2019-06-20 |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 25 | - FreeBSD >= 11.3 |
Davide Pesavento | 3ffae26 | 2021-08-27 18:48:22 -0400 | [diff] [blame] | 26 | - macOS 10.13 |
| 27 | - macOS 10.14 |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 28 | |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 29 | Prerequisites |
| 30 | ------------- |
| 31 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 32 | Required |
| 33 | ~~~~~~~~ |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 34 | |
Davide Pesavento | 71c622b | 2020-04-24 01:39:01 -0400 | [diff] [blame] | 35 | - GCC >= 7.4 or clang >= 4.0 (on Linux and FreeBSD) |
| 36 | - Xcode >= 9.0 (on macOS) |
Davide Pesavento | 78338c5 | 2020-04-20 23:00:02 -0400 | [diff] [blame] | 37 | - Python >= 3.6 |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 38 | - pkg-config |
Davide Pesavento | 78338c5 | 2020-04-20 23:00:02 -0400 | [diff] [blame] | 39 | - Boost >= 1.65.1 |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 40 | - OpenSSL >= 1.0.2 |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 41 | - SQLite 3.x |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 42 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 43 | To build ndn-cxx from source, one must first install a C++ compiler and all necessary |
| 44 | development tools and libraries: |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 45 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 46 | - On **Ubuntu** |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 47 | |
| 48 | In a terminal, enter:: |
| 49 | |
Davide Pesavento | 30ed628 | 2021-07-25 20:05:06 -0400 | [diff] [blame] | 50 | sudo apt install build-essential pkg-config python3-minimal libboost-all-dev libssl-dev libsqlite3-dev |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 51 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 52 | - On **CentOS** and **Fedora** |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 53 | |
| 54 | In a terminal, enter:: |
| 55 | |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 56 | sudo dnf install gcc-c++ pkgconf-pkg-config python3 boost-devel openssl-devel sqlite-devel |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 57 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 58 | - On **macOS** |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 59 | |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 60 | * Install either Xcode (from the App Store) or the Command Line Tools |
| 61 | (with ``xcode-select --install``) |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 62 | |
Davide Pesavento | cad94b0 | 2021-04-09 21:23:03 -0400 | [diff] [blame] | 63 | * If using Homebrew (recommended), enter the following in a terminal: |
| 64 | |
| 65 | .. code-block:: sh |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 66 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 67 | brew install boost openssl pkg-config |
Davide Pesavento | cad94b0 | 2021-04-09 21:23:03 -0400 | [diff] [blame] | 68 | brew install python # only on macOS 10.14 and earlier |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame] | 69 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 70 | .. warning:: |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame] | 71 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 72 | If a major OS upgrade is performed after installing the dependencies |
| 73 | with Homebrew, remember to reinstall all packages. |
Alexander Afanasyev | 67cb75c | 2016-06-15 12:34:58 -0700 | [diff] [blame] | 74 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 75 | - On **FreeBSD** |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 76 | |
| 77 | In a terminal, enter:: |
| 78 | |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 79 | sudo pkg install pkgconf python3 boost-libs openssl sqlite3 |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 80 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 81 | Optional |
| 82 | ~~~~~~~~ |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 83 | |
Davide Pesavento | 01cea50 | 2021-07-31 19:25:42 -0400 | [diff] [blame] | 84 | To build tutorials, man pages, and API documentation the following additional dependencies |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 85 | need to be installed: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 86 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 87 | - doxygen |
| 88 | - graphviz |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 89 | - sphinx >= 1.3 |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 90 | - sphinxcontrib-doxylink |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 91 | |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 92 | The following lists the steps to install these prerequisites on various common platforms. |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 93 | |
Davide Pesavento | 3ffae26 | 2021-08-27 18:48:22 -0400 | [diff] [blame] | 94 | .. note:: |
| 95 | On Linux, you may need to add ``$HOME/.local/bin`` to the ``PATH`` environment variable |
| 96 | for your user, for example: |
| 97 | |
| 98 | .. code-block:: sh |
| 99 | |
| 100 | export PATH="${HOME}/.local/bin${PATH:+:}${PATH}" |
| 101 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 102 | - On **Ubuntu**: |
| 103 | |
| 104 | .. code-block:: sh |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 105 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 106 | sudo apt install doxygen graphviz python3-pip |
Davide Pesavento | 30ed628 | 2021-07-25 20:05:06 -0400 | [diff] [blame] | 107 | pip3 install --user sphinx sphinxcontrib-doxylink |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 108 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 109 | - On **CentOS** and **Fedora**: |
| 110 | |
| 111 | .. code-block:: sh |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 112 | |
Davide Pesavento | cad94b0 | 2021-04-09 21:23:03 -0400 | [diff] [blame] | 113 | sudo dnf config-manager --enable powertools # on CentOS only |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 114 | sudo dnf install doxygen graphviz python3-pip |
| 115 | pip3 install --user sphinx sphinxcontrib-doxylink |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 116 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 117 | - On **macOS**: |
| 118 | |
| 119 | .. code-block:: sh |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 120 | |
| 121 | brew install doxygen graphviz |
Davide Pesavento | 30ed628 | 2021-07-25 20:05:06 -0400 | [diff] [blame] | 122 | sudo pip3 install sphinx sphinxcontrib-doxylink |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 123 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 124 | - On **FreeBSD**: |
| 125 | |
| 126 | .. code-block:: sh |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 127 | |
Davide Pesavento | d776a93 | 2020-03-20 18:42:36 -0400 | [diff] [blame] | 128 | sudo pkg install doxygen graphviz py37-sphinx |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 129 | |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 130 | Build |
| 131 | ----- |
| 132 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 133 | .. note:: |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 134 | These are instructions for regular builds of ndn-cxx (release mode). If you are |
| 135 | planning to develop the ndn-cxx code itself, you should do a :ref:`Development build`. |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 136 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 137 | To build in a terminal, change directory to the ndn-cxx root, then enter: |
| 138 | |
| 139 | .. code-block:: sh |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 140 | |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 141 | ./waf configure # on CentOS, add --without-pch |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 142 | ./waf |
| 143 | sudo ./waf install |
| 144 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 145 | By default, only the shared variant of the ndn-cxx library will be built. To build the |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 146 | static library, pass ``--enable-static`` to the ``./waf configure`` command: |
| 147 | |
| 148 | .. code-block:: sh |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 149 | |
Spyridon Mastorakis | 5ebfda6 | 2015-07-21 20:57:40 -0700 | [diff] [blame] | 150 | ./waf configure --enable-static |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 151 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 152 | To disable the build of the shared library and build only the static library, use the |
| 153 | additional ``--disable-shared`` option. Note that at least one variant of the library |
| 154 | needs to be enabled. |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 155 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 156 | .. code-block:: sh |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 157 | |
Spyridon Mastorakis | 5ebfda6 | 2015-07-21 20:57:40 -0700 | [diff] [blame] | 158 | ./waf configure --enable-static --disable-shared |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 159 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 160 | On Linux, it is necessary to run the following command after the shared library has |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 161 | been installed: |
| 162 | |
| 163 | .. code-block:: sh |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 164 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 165 | sudo ldconfig |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 166 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 167 | .. note:: |
| 168 | When the library is installed in a non-standard path (in general: not in ``/usr/lib`` |
| 169 | or ``/usr/local/lib``; on some Linux distros including Fedora: not in ``/usr/lib``), |
| 170 | additional actions may be necessary. |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 171 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 172 | The installation path should be added to ``/etc/ld.so.conf`` (or in |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 173 | ``/etc/ld.so.conf.d``) **before** running ``sudo ldconfig``. For example: |
| 174 | |
| 175 | .. code-block:: sh |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 176 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 177 | echo /usr/local/lib | sudo tee /etc/ld.so.conf.d/ndn-cxx.conf |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 178 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 179 | Alternatively, the ``LD_LIBRARY_PATH`` environment variable can be set to point to |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 180 | the installation directory of the shared library: |
| 181 | |
| 182 | .. code-block:: sh |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 183 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 184 | export LD_LIBRARY_PATH=/usr/local/lib |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 185 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 186 | The ``./waf install`` command installs the following files: |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 187 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 188 | - ``<LIBPATH>/libndn-cxx.a``: static NDN C++ library (if enabled). |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 189 | - ``<LIBPATH>/libndn-cxx.so``, ``<LIBPATH>/libndn-cxx.so.<VERSION>`` (on Linux), |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 190 | ``<LIBPATH>/libndn-cxx.dylib``, ``<LIBPATH>/libndn-cxx.<VERSION>.dylib`` (on macOS): |
| 191 | shared NDN C++ library (if enabled). |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 192 | - ``<LIBPATH>/pkgconfig/libndn-cxx.pc``: pkgconfig file storing all necessary flags to |
| 193 | build against the library. For example, if the ``pkg-config`` or ``pkgconf-pkg-config`` |
| 194 | package is installed and ``PKG_CONFIG_PATH`` is configured properly (or if |
| 195 | ``<LIBPATH>/pkgconfig`` is a default search path), the command ``pkg-config --cflags |
| 196 | --libs libndn-cxx`` will return all necessary compile and link flags for the library. |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 197 | - ``<BINPATH>/ndnsec``: tool to manage NDN keys and certificates. |
| 198 | - ``<BINPATH>/ndnsec-*``: convenience aliases for ``ndnsec`` tools. |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 199 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 200 | If configured with tests (``./waf configure --with-tests``), the above commands |
| 201 | will also produce: |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 202 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 203 | - ``build/unit-tests``: a unit test binary for the library. |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 204 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 205 | 1.5 GB available memory per CPU core is necessary for efficient compilation. On a |
| 206 | multi-core machine with less than 1.5 GB available memory per CPU core, limit the |
| 207 | objects being compiled in parallel with ``./waf -jN``, where N is the amount of |
| 208 | available memory divided by 1.5 GB (e.g., ``./waf -j2`` for 3 GB of memory). This |
| 209 | should avoid memory thrashing and result in faster compilation. |
Junxiao Shi | e04bd83 | 2014-11-29 23:02:38 -0700 | [diff] [blame] | 210 | |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 211 | Build with examples |
| 212 | ------------------- |
| 213 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 214 | By default, the examples in the ``examples/`` directory will not be built. To enable |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 215 | them, pass ``--with-examples`` during the configuration step: |
| 216 | |
| 217 | .. code-block:: sh |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 218 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 219 | ./waf configure --with-examples # on CentOS, add --without-pch |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 220 | ./waf |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 221 | sudo ./waf install |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 222 | sudo ldconfig # on Linux only |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 223 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 224 | To run the examples: |
| 225 | |
| 226 | .. code-block:: sh |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 227 | |
| 228 | # trivial producer app |
| 229 | ./build/examples/producer |
| 230 | |
| 231 | # trivial consumer app |
| 232 | ./build/examples/consumer |
| 233 | |
| 234 | # trivial consumer app with timers |
| 235 | ./build/examples/consumer-with-timer |
| 236 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 237 | If you want to make a new sample application, just create a ``.cpp`` file inside the |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 238 | ``examples/`` directory and it will be compiled during the next run of ``./waf``: |
| 239 | |
| 240 | .. code-block:: sh |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 241 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 242 | cp examples/consumer.cpp examples/my-new-app.cpp |
| 243 | ... # edit examples/my-new-app.cpp with your preferred editor |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 244 | ./waf |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 245 | sudo ./waf install |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 246 | sudo ldconfig # on Linux only |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 247 | ./build/examples/my-new-app |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 248 | |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 249 | Debug symbols |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 250 | ------------- |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 251 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 252 | The default compiler flags include debug symbols in binaries. This should provide |
| 253 | more meaningful debugging information if ndn-cxx or your application crashes. |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 254 | |
Eric Newberry | bdfb53a | 2020-10-01 10:43:46 -0700 | [diff] [blame] | 255 | If this is not desired, the default flags can be overridden to disable debug symbols. |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 256 | The following example shows how to completely disable debug symbols and configure |
| 257 | ndn-cxx to be installed into ``/usr`` with configuration in the ``/etc`` directory. |
| 258 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 259 | .. code-block:: sh |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 260 | |
| 261 | CXXFLAGS="-O2" ./waf configure --prefix=/usr --sysconfdir=/etc |
| 262 | ./waf |
| 263 | sudo ./waf install |
| 264 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 265 | Customizing the compiler |
| 266 | ------------------------ |
Alexander Afanasyev | 7ed2943 | 2015-06-05 18:01:16 -0700 | [diff] [blame] | 267 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 268 | To build ndn-cxx with a different compiler (rather than the platform default), set the |
| 269 | ``CXX`` environment variable to point to the compiler binary. For example, to build |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 270 | with clang on Linux, use the following: |
| 271 | |
| 272 | .. code-block:: sh |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 273 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 274 | CXX=clang++ ./waf configure |
| 275 | |
| 276 | Building the documentation |
| 277 | -------------------------- |
| 278 | |
Eric Newberry | bdfb53a | 2020-10-01 10:43:46 -0700 | [diff] [blame] | 279 | Tutorials and API documentation can be built using the following commands: |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 280 | |
| 281 | .. code-block:: sh |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 282 | |
| 283 | # Full set of documentation (tutorials + API) in build/docs |
| 284 | ./waf docs |
| 285 | |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 286 | # Only tutorials in build/docs |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 287 | ./waf sphinx |
| 288 | |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 289 | # Only API docs in build/docs/doxygen |
Sepehr Abdous | 4fc6db2 | 2018-08-22 15:26:06 -0700 | [diff] [blame] | 290 | ./waf doxygen |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 291 | |
Davide Pesavento | 01cea50 | 2021-07-31 19:25:42 -0400 | [diff] [blame] | 292 | If ``sphinx-build`` is detected during ``./waf configure``, man pages will automatically |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 293 | be built and installed during the normal build process (i.e., during ``./waf`` and |
Davide Pesavento | 01cea50 | 2021-07-31 19:25:42 -0400 | [diff] [blame] | 294 | ``./waf install``). By default, man pages will be installed into ``${PREFIX}/share/man`` |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 295 | (the default value for ``PREFIX`` is ``/usr/local``). This location can be changed |
| 296 | during the ``./waf configure`` stage using the ``--prefix``, ``--datarootdir``, or |
| 297 | ``--mandir`` options. |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 298 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 299 | For further details, please refer to ``./waf --help``. |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 300 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 301 | .. _Development build: |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 302 | |
| 303 | Development build |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 304 | ----------------- |
| 305 | |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 306 | The following is the suggested build procedure for development builds: |
| 307 | |
| 308 | .. code-block:: sh |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 309 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 310 | ./waf configure --debug --with-tests # on CentOS, add --without-pch |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 311 | ./waf |
| 312 | sudo ./waf install |
Davide Pesavento | 2349e28 | 2020-03-24 14:28:03 -0400 | [diff] [blame] | 313 | sudo ldconfig # on Linux only |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 314 | |
Davide Pesavento | ab7300b | 2020-04-09 00:51:41 -0400 | [diff] [blame] | 315 | In a development build, most compiler optimizations will be disabled and all warnings |
| 316 | will be treated as errors. This default behavior can be overridden by setting the |
Davide Pesavento | 933a567 | 2020-07-03 22:32:43 -0400 | [diff] [blame] | 317 | ``CXXFLAGS`` environment variable before running ``./waf configure``, for example: |
| 318 | |
| 319 | .. code-block:: sh |
Alexander Afanasyev | c5452c5 | 2014-04-29 17:21:51 -0700 | [diff] [blame] | 320 | |
| 321 | CXXFLAGS="-O1 -g3" ./waf configure --debug --with-tests |
| 322 | ... |