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