| 1 | \page buildosx Building on OSX |
| 2 | |
| 3 | ## 1. Toolchain |
| 4 | |
| 5 | Before compiling make sure you have all the tools installed. |
| 6 | |
| 7 | 1. To install the dependencies, this guide will use Homebrew which has an [installation guide on their project page](https://brew.sh/). |
| 8 | 2. This project uses CMake to generate the makefiles. Install it with `brew install cmake`. |
| 9 | |
| 10 | ## 2. Install External Dependencies |
| 11 | |
| 12 | ```bash |
| 13 | brew install openssl pkgconfig |
| 14 | ``` |
| 15 | |
| 16 | \note Usually, you do not need pkgconfig. However, it seems that it throws errors about openssl without. |
| 17 | |
| 18 | For voice support, additional dependency is required: |
| 19 | |
| 20 | ```bash |
| 21 | brew install opus |
| 22 | ``` |
| 23 | |
| 24 | ## 3. Build Source Code |
| 25 | |
| 26 | ```bash |
| 27 | cmake -B ./build |
| 28 | cmake --build ./build -j8 |
| 29 | ``` |
| 30 | |
| 31 | Replace the number after `-j` with a number suitable for your setup, usually the same as the number of cores on your machine. `cmake` will fetch any dependencies that are required for you and ensure they are compiled alongside the library. |
| 32 | |
| 33 | ## 4. Install Globally |
| 34 | |
| 35 | ```bash |
| 36 | cd build |
| 37 | sudo make install |
| 38 | ``` |
| 39 | |
| 40 | ## 5. Installation to a Different Directory |
| 41 | |
| 42 | If you want to install the library, its dependencies, and header files to a different directory, specify this directory when running `cmake`: |
| 43 | |
| 44 | ```bash |
| 45 | cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install |
| 46 | ``` |
| 47 | |
| 48 | Then once the build is complete, run `sudo make install` to install to the location you specified. |
| 49 | |
| 50 | ## 6. Using the Library |
| 51 | |
| 52 | Once installed, you can make use of the library in standalone programs simply by including it and linking to it: |
| 53 | |
| 54 | ```bash |
| 55 | clang++ -std=c++20 -ldpp mydppbot.cpp -o dppbot |
| 56 | ``` |
| 57 | |
| 58 | The important flags in this command-line are: |
| 59 | |
| 60 | * `-std=c++20` - Required to compile the headers |
| 61 | * `-ldpp` - Link to libdpp.dylib |
| 62 | * `mydppbot.cpp` - Your source code |
| 63 | * `dppbot` - The name of the executable to make |
| 64 | |
| 65 | \include{doc} install_prebuilt_footer.dox |
| 66 | |
| 67 | **Have fun!** |