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