1*a58d3d2aSXin Li# Using the Meson Build System for the Opus Project 2*a58d3d2aSXin Li 3*a58d3d2aSXin LiThis guide provides instructions for using the Meson build system to build the Opus project with various configuration options. Meson is a fast and efficient build system that aims to be easy to use and understand. 4*a58d3d2aSXin Li 5*a58d3d2aSXin LiPlease note that software documentation can sometimes become outdated as new versions are released. For the most up-to-date and accurate information, we recommend referring to the official Meson documentation, which can be found at [mesonbuild.com](https://mesonbuild.com/). 6*a58d3d2aSXin Li 7*a58d3d2aSXin Li## Prerequisites 8*a58d3d2aSXin Li 9*a58d3d2aSXin LiBefore proceeding, ensure that you have the following prerequisites installed: 10*a58d3d2aSXin Li 11*a58d3d2aSXin Li- [Meson](https://mesonbuild.com/Quick-guide.html) 12*a58d3d2aSXin Li- [Ninja](https://ninja-build.org/) (recommended as the build backend, although other backends are also available) 13*a58d3d2aSXin Li- [Git](https://git-scm.com/) (optional, but recommended for version control integration) 14*a58d3d2aSXin Li- A working C compiler 15*a58d3d2aSXin Li 16*a58d3d2aSXin Li## Build and Test Instructions 17*a58d3d2aSXin Li 18*a58d3d2aSXin LiFollow the steps below to build the Opus project using Meson. 19*a58d3d2aSXin Li 20*a58d3d2aSXin Li### Check out Source 21*a58d3d2aSXin LiClone the Opus repository using Git: 22*a58d3d2aSXin Li 23*a58d3d2aSXin Li```shell 24*a58d3d2aSXin Ligit clone https://gitlab.xiph.org/xiph/opus 25*a58d3d2aSXin Licd opus 26*a58d3d2aSXin Li``` 27*a58d3d2aSXin Li 28*a58d3d2aSXin Li### Configure 29*a58d3d2aSXin LiTo configure the build with Meson, you can set the desired configuration options using the -D flag followed by the option name and value. For the Opus project-specific build options, please refer to the [meson_options.txt](./../meson_options.txt) file. For general Meson options use the command meson `setup --help` to get a list of these options. 30*a58d3d2aSXin Li 31*a58d3d2aSXin LiFor example, to setup and disable tests, use the following command: 32*a58d3d2aSXin Li 33*a58d3d2aSXin Li```shell 34*a58d3d2aSXin Limeson setup builddir -Dtests=disabled 35*a58d3d2aSXin Li``` 36*a58d3d2aSXin Li 37*a58d3d2aSXin Li### Build 38*a58d3d2aSXin Li 39*a58d3d2aSXin Li```shell 40*a58d3d2aSXin Limeson compile -C builddir 41*a58d3d2aSXin Li``` 42*a58d3d2aSXin Li 43*a58d3d2aSXin LiAfter a successful build, you can find the compiled Opus library and associated files in the builddir directory. 44*a58d3d2aSXin Li 45*a58d3d2aSXin Li### Testing with Meson 46*a58d3d2aSXin Li 47*a58d3d2aSXin LiOpus provides a comprehensive test suite to ensure the functionality and correctness of the project. You can execute the tests using Meson's built-in testing functionality. 48*a58d3d2aSXin Li 49*a58d3d2aSXin LiTo run the Opus tests using Meson: 50*a58d3d2aSXin Li 51*a58d3d2aSXin Li```shell 52*a58d3d2aSXin Limeson test -C builddir 53*a58d3d2aSXin Li``` 54*a58d3d2aSXin Li 55*a58d3d2aSXin Li## Platform Support and Bug Reporting 56*a58d3d2aSXin Li 57*a58d3d2aSXin LiThe Opus Meson build system aims to provide support for the same platforms as [GStreamer](https://gstreamer.freedesktop.org/), a widely used multimedia framework. GStreamer supports a wide range of operating systems and platforms, including Linux, Windows (MSVC and MingW), Android, macOS, iOS, and various BSD systems. 58*a58d3d2aSXin Li 59*a58d3d2aSXin LiWhile efforts are made to ensure compatibility and stability across these platforms, bugs or issues may still arise in specific configurations. If you encounter any problems during the configuration process or while building the Opus project, we encourage you to file an issue in the [project's issue tracker](https://gitlab.xiph.org/xiph/opus/-/issues). 60*a58d3d2aSXin Li 61*a58d3d2aSXin LiWhen reporting an issue, please provide the following information to help us understand and effectively reproduce the configuration problem: 62*a58d3d2aSXin Li 63*a58d3d2aSXin Li1. Detailed description of the issue, including any error messages or unexpected behavior observed. 64*a58d3d2aSXin Li2. Steps to reproduce the problem, including the Meson command and any specific configuration options used. 65*a58d3d2aSXin Li3. Operating system and version (e.g., Windows 10, macOS Big Sur, Ubuntu 20.04). 66*a58d3d2aSXin Li4. Meson version (e.g., Meson 0.60.0). 67*a58d3d2aSXin Li5. Any relevant information about the platform, toolchain, or dependencies used. 68*a58d3d2aSXin Li6. Additional context or details that might assist in troubleshooting the issue. 69*a58d3d2aSXin Li 70*a58d3d2aSXin LiBy providing thorough information when reporting configuration issues, you contribute to improving the Opus project's compatibility and reliability across different platforms. 71*a58d3d2aSXin Li 72*a58d3d2aSXin LiWe appreciate your help in identifying and addressing any configuration-related problems, ensuring a better experience for all users of the Opus project. 73*a58d3d2aSXin Li 74*a58d3d2aSXin Li## Platform Specific Examples 75*a58d3d2aSXin Li 76*a58d3d2aSXin LiNote: Examples can become outdated. Always refer to the documentation for the latest reference. 77*a58d3d2aSXin Li 78*a58d3d2aSXin Li### Windows Visual Studio 79*a58d3d2aSXin Li 80*a58d3d2aSXin LiTo generate Visual Studio projects, Meson needs to know the settings of your installed version of Visual Studio. The recommended approach is to run Meson under the Visual Studio Command Prompt. 81*a58d3d2aSXin Li 82*a58d3d2aSXin LiYou can find the Visual Studio Command Prompt by searching from the Start Menu. However, the name varies for each Visual Studio version. For Visual Studio 2022, look for "x64 Native Tools Command Prompt for VS 2022". The following steps remain the same: 83*a58d3d2aSXin Li 84*a58d3d2aSXin Li```shell 85*a58d3d2aSXin Limeson setup builddir -Dtests=enabled --backend vs 86*a58d3d2aSXin Li``` 87*a58d3d2aSXin Li 88*a58d3d2aSXin LiFor more information about the Visual Studio backend options and additional customization, please refer to the [Using with Visual Studio](https://mesonbuild.com/Using-with-Visual-Studio.html) documentation.