1*89a0ef05SAndroid Build Coastguard Worker## libultrahdr CMake Build Instructions 2*89a0ef05SAndroid Build Coastguard Worker 3*89a0ef05SAndroid Build Coastguard Worker[](https://github.com/google/libultrahdr/actions/workflows/cmake_linux.yml?query=event%3Apush) 4*89a0ef05SAndroid Build Coastguard Worker[](https://github.com/google/libultrahdr/actions/workflows/cmake_mac.yml?query=event%3Apush) 5*89a0ef05SAndroid Build Coastguard Worker[](https://github.com/google/libultrahdr/actions/workflows/cmake_win.yml?query=event%3Apush) 6*89a0ef05SAndroid Build Coastguard Worker[](https://github.com/google/libultrahdr/actions/workflows/cmake_android.yml?query=event%3Apush) 7*89a0ef05SAndroid Build Coastguard Worker[](https://introspector.oss-fuzz.com/project-profile?project=libultrahdr) 8*89a0ef05SAndroid Build Coastguard Worker 9*89a0ef05SAndroid Build Coastguard Worker### Requirements 10*89a0ef05SAndroid Build Coastguard Worker 11*89a0ef05SAndroid Build Coastguard Worker- [CMake](http://www.cmake.org) v3.15 or later 12*89a0ef05SAndroid Build Coastguard Worker- C++ compiler, supporting at least C++17. 13*89a0ef05SAndroid Build Coastguard Worker- libultrahdr uses jpeg compression format to store sdr image and gainmap quotient. 14*89a0ef05SAndroid Build Coastguard Worker So, libjpeg or any other jpeg codec that is ABI and API compatible with libjpeg. 15*89a0ef05SAndroid Build Coastguard Worker 16*89a0ef05SAndroid Build Coastguard WorkerThe library offers a way to skip installing libjpeg by passing `UHDR_BUILD_DEPS=1` 17*89a0ef05SAndroid Build Coastguard Workerat the time of configure. That is, `cmake -DUHDR_BUILD_DEPS=1` will clone jpeg codec 18*89a0ef05SAndroid Build Coastguard Workerfrom [link](https://github.com/libjpeg-turbo/libjpeg-turbo.git) and include it in 19*89a0ef05SAndroid Build Coastguard Workerthe build process. This is however not recommended. 20*89a0ef05SAndroid Build Coastguard Worker 21*89a0ef05SAndroid Build Coastguard WorkerIf jpeg is included in the build process then, 22*89a0ef05SAndroid Build Coastguard Worker- C compiler 23*89a0ef05SAndroid Build Coastguard Worker- For building x86/x86_64 SIMD optimizations, [NASM](http://www.nasm.us) or 24*89a0ef05SAndroid Build Coastguard Worker [Yasm](http://yasm.tortall.net). 25*89a0ef05SAndroid Build Coastguard Worker * If using NASM, 2.13 or later is required. 26*89a0ef05SAndroid Build Coastguard Worker * If using Yasm, 1.2.0 or later is required. 27*89a0ef05SAndroid Build Coastguard Worker 28*89a0ef05SAndroid Build Coastguard Worker### CMake Options 29*89a0ef05SAndroid Build Coastguard Worker 30*89a0ef05SAndroid Build Coastguard WorkerThere are a few options that can be passed to CMake to modify how the code 31*89a0ef05SAndroid Build Coastguard Workeris built.<br> 32*89a0ef05SAndroid Build Coastguard WorkerTo set these options and parameters, use `-D<Parameter_name>=<value>`. 33*89a0ef05SAndroid Build Coastguard Worker 34*89a0ef05SAndroid Build Coastguard WorkerAll CMake options are passed at configure time, i.e., by running 35*89a0ef05SAndroid Build Coastguard Worker`cmake -DOPTION_ONE=1 -DOPTION_TWO=0 ...` <br> 36*89a0ef05SAndroid Build Coastguard Workerbefore running `cmake --build ...`<br> 37*89a0ef05SAndroid Build Coastguard Worker 38*89a0ef05SAndroid Build Coastguard WorkerFor example, to build unit tests in a new subdirectory called 'build', run: 39*89a0ef05SAndroid Build Coastguard Worker 40*89a0ef05SAndroid Build Coastguard Worker```sh 41*89a0ef05SAndroid Build Coastguard Workercmake -G "Unix Makefiles" -S. -Bbuild -DUHDR_BUILD_TESTS=1 ../ 42*89a0ef05SAndroid Build Coastguard Worker``` 43*89a0ef05SAndroid Build Coastguard Workerand then build with: 44*89a0ef05SAndroid Build Coastguard Worker 45*89a0ef05SAndroid Build Coastguard Worker```sh 46*89a0ef05SAndroid Build Coastguard Workercmake --build build 47*89a0ef05SAndroid Build Coastguard Worker``` 48*89a0ef05SAndroid Build Coastguard Worker 49*89a0ef05SAndroid Build Coastguard WorkerFollowing is a list of available options: 50*89a0ef05SAndroid Build Coastguard Worker 51*89a0ef05SAndroid Build Coastguard Worker| CMake Option | Default Value | Notes | 52*89a0ef05SAndroid Build Coastguard Worker|:-------------|:--------------|:-----| 53*89a0ef05SAndroid Build Coastguard Worker| `CMAKE_BUILD_TYPE` | Release | See CMake documentation [here](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html). | 54*89a0ef05SAndroid Build Coastguard Worker| `BUILD_SHARED_LIBS` | ON | See CMake documentation [here](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html). <ul><li> If `BUILD_SHARED_LIBS` is **OFF**, in the linking phase, static versions of dependencies are chosen. However, the executable targets are not purely static because the system libraries used are still dynamic. </li></ul> | 55*89a0ef05SAndroid Build Coastguard Worker| `UHDR_BUILD_EXAMPLES` | ON | Build sample application. This application demonstrates how to use [ultrahdr_api.h](../ultrahdr_api.h). | 56*89a0ef05SAndroid Build Coastguard Worker| `UHDR_BUILD_TESTS` | OFF | Build Unit Tests. Mostly for Devs. During development, different modules of libuhdr library are validated using GoogleTest framework. Developers after making changes to library are expected to run these tests to ensure every thing is functional. | 57*89a0ef05SAndroid Build Coastguard Worker| `UHDR_BUILD_BENCHMARK` | OFF | Build Benchmark Tests. These are for profiling libuhdr encode/decode API. Resources used by benchmark tests are shared [here](https://storage.googleapis.com/android_media/external/libultrahdr/benchmark/UltrahdrBenchmarkTestRes-1.1.zip). These are downloaded and extracted automatically during the build process for later benchmarking. <ul><li> Benchmark tests are not supported on Windows and this parameter is forced to **OFF** internally while building on **WIN32** platforms. </li></ul>| 58*89a0ef05SAndroid Build Coastguard Worker| `UHDR_BUILD_FUZZERS` | OFF | Build Fuzz Test Applications. Mostly for Devs. <ul><li> Fuzz applications are built by instrumenting the entire software suite. This includes dependency libraries. This is done by forcing `UHDR_BUILD_DEPS` to **ON** internally. </li></ul> | 59*89a0ef05SAndroid Build Coastguard Worker| `UHDR_BUILD_DEPS` | OFF | Clone and Build project dependencies and not use pre-installed packages. | 60*89a0ef05SAndroid Build Coastguard Worker| `UHDR_BUILD_JAVA` | OFF | Build JNI wrapper, Java front-end classes and Java sample application. | 61*89a0ef05SAndroid Build Coastguard Worker| `UHDR_ENABLE_LOGS` | OFF | Build with verbose logging. | 62*89a0ef05SAndroid Build Coastguard Worker| `UHDR_ENABLE_INSTALL` | ON | Enable install and uninstall targets for libuhdr package. <ul><li> For system wide installation it is best if dependencies are acquired from OS package manager instead of building from source. This is to avoid conflicts with software that is using a different version of the said dependency and also links to libuhdr. So if `UHDR_BUILD_DEPS` is **ON** then `UHDR_ENABLE_INSTALL` is forced to **OFF** internally. | 63*89a0ef05SAndroid Build Coastguard Worker| `UHDR_ENABLE_INTRINSICS` | ON | Build with SIMD acceleration. Sections of libuhdr are accelerated for Arm Neon architectures and these are enabled. <ul><li> For x86/x86_64 architectures currently no SIMD acceleration is present. Consequently this option has no effect. </li><li> This parameter has no effect no SIMD configuration settings of dependencies. </li></ul> | 64*89a0ef05SAndroid Build Coastguard Worker| `UHDR_ENABLE_GLES` | OFF | Build with GPU acceleration. | 65*89a0ef05SAndroid Build Coastguard Worker| `UHDR_ENABLE_WERROR` | OFF | Enable -Werror when building. | 66*89a0ef05SAndroid Build Coastguard Worker| `UHDR_MAX_DIMENSION` | 8192 | Maximum dimension supported by the library. The library defaults to handling images upto resolution 8192x8192. For different resolution needs use this option. For example, `-DUHDR_MAX_DIMENSION=4096`. | 67*89a0ef05SAndroid Build Coastguard Worker| `UHDR_SANITIZE_OPTIONS` | OFF | Build library with sanitize options. Values set to this parameter are passed to directly to compilation option `-fsanitize`. For example, `-DUHDR_SANITIZE_OPTIONS=address,undefined` adds `-fsanitize=address,undefined` to the list of compilation options. CMake configuration errors are raised if the compiler does not support these flags. This is useful during fuzz testing. <ul><li> As `-fsanitize` is an instrumentation option, dependencies are also built from source instead of using pre-builts. This is done by forcing `UHDR_BUILD_DEPS` to **ON** internally. </li></ul> | 68*89a0ef05SAndroid Build Coastguard Worker| `UHDR_BUILD_PACKAGING` | OFF | Build distribution packages using CPack. | 69*89a0ef05SAndroid Build Coastguard Worker| | | | 70*89a0ef05SAndroid Build Coastguard Worker 71*89a0ef05SAndroid Build Coastguard Worker### Generator 72*89a0ef05SAndroid Build Coastguard Worker 73*89a0ef05SAndroid Build Coastguard WorkerThe CMake generator preferred is ninja. Consequently, ninja is added to the list of prerequisite packages. This need not be the case. If the platform is equipped with a different generator, it can be tried and ninja installation can be skipped. 74*89a0ef05SAndroid Build Coastguard Worker 75*89a0ef05SAndroid Build Coastguard Worker### Build Steps 76*89a0ef05SAndroid Build Coastguard Worker 77*89a0ef05SAndroid Build Coastguard WorkerCheck out the source code: 78*89a0ef05SAndroid Build Coastguard Worker 79*89a0ef05SAndroid Build Coastguard Worker```sh 80*89a0ef05SAndroid Build Coastguard Workergit clone https://github.com/google/libultrahdr.git 81*89a0ef05SAndroid Build Coastguard Workercd libultrahdr 82*89a0ef05SAndroid Build Coastguard Workermkdir build_directory 83*89a0ef05SAndroid Build Coastguard Workercd build_directory 84*89a0ef05SAndroid Build Coastguard Worker``` 85*89a0ef05SAndroid Build Coastguard Worker 86*89a0ef05SAndroid Build Coastguard Worker### Linux Platform 87*89a0ef05SAndroid Build Coastguard Worker 88*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: 89*89a0ef05SAndroid Build Coastguard Worker 90*89a0ef05SAndroid Build Coastguard Worker```sh 91*89a0ef05SAndroid Build Coastguard Workersudo apt install cmake pkg-config libjpeg-dev ninja-build 92*89a0ef05SAndroid Build Coastguard Worker``` 93*89a0ef05SAndroid Build Coastguard Worker 94*89a0ef05SAndroid Build Coastguard WorkerCompile and Test: 95*89a0ef05SAndroid Build Coastguard Worker 96*89a0ef05SAndroid Build Coastguard Worker```sh 97*89a0ef05SAndroid Build Coastguard Workercmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUHDR_BUILD_TESTS=1 ../ 98*89a0ef05SAndroid Build Coastguard Workerninja 99*89a0ef05SAndroid Build Coastguard Workerctest 100*89a0ef05SAndroid Build Coastguard Worker``` 101*89a0ef05SAndroid Build Coastguard Worker 102*89a0ef05SAndroid Build Coastguard WorkerThis will generate the following files under `build_directory`: 103*89a0ef05SAndroid Build Coastguard Worker 104*89a0ef05SAndroid Build Coastguard Worker**libuhdr.so.{version}** - Shared library for the libuhdr API <br> 105*89a0ef05SAndroid Build Coastguard Worker**libuhdr.so** - Symlink to shared library <br> 106*89a0ef05SAndroid Build Coastguard Worker**libuhdr.a** - Static link library for the libuhdr API <br> 107*89a0ef05SAndroid Build Coastguard Worker**libuhdr.pc** - libuhdr pkg-config file <br> 108*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_app** - sample application <br> 109*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_unit_test** - unit tests <br> 110*89a0ef05SAndroid Build Coastguard Worker 111*89a0ef05SAndroid Build Coastguard WorkerInstallation: 112*89a0ef05SAndroid Build Coastguard Worker 113*89a0ef05SAndroid Build Coastguard Worker```sh 114*89a0ef05SAndroid Build Coastguard Workersudo ninja install 115*89a0ef05SAndroid Build Coastguard Worker``` 116*89a0ef05SAndroid Build Coastguard Worker 117*89a0ef05SAndroid Build Coastguard WorkerThis installs the headers, pkg-config, and shared libraries. By default the headers are put in `/usr/local/include/`, libraries in `/usr/local/lib/` and pkg-config file in `/usr/local/lib/pkgconfig/`. You may need to add path `/usr/local/lib/` to `LD_LIBRARY_PATH` if binaries linking with ultrahdr library are unable to load it at run time. e.g. `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/`. 118*89a0ef05SAndroid Build Coastguard Worker 119*89a0ef05SAndroid Build Coastguard WorkerUninstallation: 120*89a0ef05SAndroid Build Coastguard Worker 121*89a0ef05SAndroid Build Coastguard Worker```sh 122*89a0ef05SAndroid Build Coastguard Workersudo ninja uninstall 123*89a0ef05SAndroid Build Coastguard Worker``` 124*89a0ef05SAndroid Build Coastguard Worker 125*89a0ef05SAndroid Build Coastguard Worker### macOS Platform 126*89a0ef05SAndroid Build Coastguard Worker 127*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: 128*89a0ef05SAndroid Build Coastguard Worker 129*89a0ef05SAndroid Build Coastguard Worker```sh 130*89a0ef05SAndroid Build Coastguard Workerbrew install cmake pkg-config jpeg ninja 131*89a0ef05SAndroid Build Coastguard Worker``` 132*89a0ef05SAndroid Build Coastguard Worker 133*89a0ef05SAndroid Build Coastguard WorkerCompile and Test: 134*89a0ef05SAndroid Build Coastguard Worker 135*89a0ef05SAndroid Build Coastguard Worker```sh 136*89a0ef05SAndroid Build Coastguard Workercmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUHDR_BUILD_TESTS=1 ../ 137*89a0ef05SAndroid Build Coastguard Workerninja 138*89a0ef05SAndroid Build Coastguard Workerctest 139*89a0ef05SAndroid Build Coastguard Worker``` 140*89a0ef05SAndroid Build Coastguard Worker 141*89a0ef05SAndroid Build Coastguard WorkerThis will generate the following files under `build_directory`: 142*89a0ef05SAndroid Build Coastguard Worker 143*89a0ef05SAndroid Build Coastguard Worker**libuhdr.{version}.dylib** - Shared library for the libuhdr API <br> 144*89a0ef05SAndroid Build Coastguard Worker**libuhdr.dylib** - Symlink to shared library <br> 145*89a0ef05SAndroid Build Coastguard Worker**libuhdr.a** - Static link library for the libuhdr API <br> 146*89a0ef05SAndroid Build Coastguard Worker**libuhdr.pc** - libuhdr pkg-config file <br> 147*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_app** - sample application <br> 148*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_unit_test** - unit tests <br> 149*89a0ef05SAndroid Build Coastguard Worker 150*89a0ef05SAndroid Build Coastguard WorkerInstallation: 151*89a0ef05SAndroid Build Coastguard Worker 152*89a0ef05SAndroid Build Coastguard Worker```sh 153*89a0ef05SAndroid Build Coastguard Workersudo ninja install 154*89a0ef05SAndroid Build Coastguard Worker``` 155*89a0ef05SAndroid Build Coastguard Worker 156*89a0ef05SAndroid Build Coastguard WorkerThis installs the headers, pkg-config, and shared libraries. By default the headers are put in `/usr/local/include/`, libraries in `/usr/local/lib/` and pkg-config file in `/usr/local/lib/pkgconfig/`. You may need to add path `/usr/local/lib/` to `DYLD_FALLBACK_LIBRARY_PATH` if binaries are unable to load uhdr library e.g. `export DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/usr/local/lib/`. 157*89a0ef05SAndroid Build Coastguard Worker 158*89a0ef05SAndroid Build Coastguard WorkerUninstallation: 159*89a0ef05SAndroid Build Coastguard Worker 160*89a0ef05SAndroid Build Coastguard Worker```sh 161*89a0ef05SAndroid Build Coastguard Workersudo ninja uninstall 162*89a0ef05SAndroid Build Coastguard Worker``` 163*89a0ef05SAndroid Build Coastguard Worker 164*89a0ef05SAndroid Build Coastguard Worker### Windows Platform - MSYS2 Env 165*89a0ef05SAndroid Build Coastguard Worker 166*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: 167*89a0ef05SAndroid Build Coastguard Worker 168*89a0ef05SAndroid Build Coastguard Worker```sh 169*89a0ef05SAndroid Build Coastguard Workerpacman -S mingw-w64-ucrt-x86_64-libjpeg-turbo mingw-w64-ucrt-x86_64-ninja 170*89a0ef05SAndroid Build Coastguard Worker``` 171*89a0ef05SAndroid Build Coastguard Worker 172*89a0ef05SAndroid Build Coastguard WorkerCompile and Test: 173*89a0ef05SAndroid Build Coastguard Worker 174*89a0ef05SAndroid Build Coastguard Worker```sh 175*89a0ef05SAndroid Build Coastguard Workercmake -G Ninja -DUHDR_BUILD_TESTS=1 ../ 176*89a0ef05SAndroid Build Coastguard Workerninja 177*89a0ef05SAndroid Build Coastguard Workerctest 178*89a0ef05SAndroid Build Coastguard Worker``` 179*89a0ef05SAndroid Build Coastguard Worker 180*89a0ef05SAndroid Build Coastguard WorkerThis will generate the following files under `build_directory`: 181*89a0ef05SAndroid Build Coastguard Worker 182*89a0ef05SAndroid Build Coastguard Worker**libuhdr.dll** - Shared library for the libuhdr API <br> 183*89a0ef05SAndroid Build Coastguard Worker**libuhdr.dll.a** - Import library for the libuhdr API <br> 184*89a0ef05SAndroid Build Coastguard Worker**libuhdr.a** - Static link library for the libuhdr API <br> 185*89a0ef05SAndroid Build Coastguard Worker**libuhdr.pc** - libuhdr pkg-config file <br> 186*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_app** - sample application <br> 187*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_unit_test** - unit tests <br> 188*89a0ef05SAndroid Build Coastguard Worker 189*89a0ef05SAndroid Build Coastguard Worker### Windows Platform - MSVC Env 190*89a0ef05SAndroid Build Coastguard Worker 191*89a0ef05SAndroid Build Coastguard Worker#### IDE 192*89a0ef05SAndroid Build Coastguard Worker 193*89a0ef05SAndroid Build Coastguard WorkerCompile and Test: 194*89a0ef05SAndroid Build Coastguard Worker 195*89a0ef05SAndroid Build Coastguard Worker```sh 196*89a0ef05SAndroid Build Coastguard Workercmake -G "Visual Studio 16 2019" -DUHDR_BUILD_DEPS=1 -DUHDR_BUILD_TESTS=1 ../ 197*89a0ef05SAndroid Build Coastguard Workercmake --build ./ --config=Release 198*89a0ef05SAndroid Build Coastguard Workerctest -C Release 199*89a0ef05SAndroid Build Coastguard Worker``` 200*89a0ef05SAndroid Build Coastguard Worker 201*89a0ef05SAndroid Build Coastguard Worker#### Command Line 202*89a0ef05SAndroid Build Coastguard Worker 203*89a0ef05SAndroid Build Coastguard WorkerCompile and Test: 204*89a0ef05SAndroid Build Coastguard Worker 205*89a0ef05SAndroid Build Coastguard Worker```sh 206*89a0ef05SAndroid Build Coastguard Workercmake -G "NMake Makefiles" -DUHDR_BUILD_DEPS=1 -DUHDR_BUILD_TESTS=1 ../ 207*89a0ef05SAndroid Build Coastguard Workercmake --build ./ 208*89a0ef05SAndroid Build Coastguard Workerctest 209*89a0ef05SAndroid Build Coastguard Worker``` 210*89a0ef05SAndroid Build Coastguard Worker 211*89a0ef05SAndroid Build Coastguard WorkerThis will generate the following files under `build_directory`: 212*89a0ef05SAndroid Build Coastguard Worker 213*89a0ef05SAndroid Build Coastguard Worker**uhdr.dll** - Shared library for the libuhdr API <br> 214*89a0ef05SAndroid Build Coastguard Worker**uhdr.lib** - Import library for the libuhdr API <br> 215*89a0ef05SAndroid Build Coastguard Worker**uhdr-static.lib** - Static link library for the libuhdr API <br> 216*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_app** - sample application <br> 217*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_unit_test** - unit tests <br> 218*89a0ef05SAndroid Build Coastguard Worker 219*89a0ef05SAndroid Build Coastguard Worker### Cross-Compilation - Build System Linux 220*89a0ef05SAndroid Build Coastguard Worker 221*89a0ef05SAndroid Build Coastguard Worker#### Target - Linux Platform - Armv7 Arch 222*89a0ef05SAndroid Build Coastguard Worker 223*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: 224*89a0ef05SAndroid Build Coastguard Worker 225*89a0ef05SAndroid Build Coastguard Worker```sh 226*89a0ef05SAndroid Build Coastguard Workersudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf 227*89a0ef05SAndroid Build Coastguard Worker``` 228*89a0ef05SAndroid Build Coastguard Worker 229*89a0ef05SAndroid Build Coastguard WorkerCompile: 230*89a0ef05SAndroid Build Coastguard Worker 231*89a0ef05SAndroid Build Coastguard Worker```sh 232*89a0ef05SAndroid Build Coastguard Workercmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/arm-linux-gnueabihf.cmake -DUHDR_BUILD_DEPS=1 ../ 233*89a0ef05SAndroid Build Coastguard Workerninja 234*89a0ef05SAndroid Build Coastguard Worker``` 235*89a0ef05SAndroid Build Coastguard Worker 236*89a0ef05SAndroid Build Coastguard Worker#### Target - Linux Platform - Armv8 Arch 237*89a0ef05SAndroid Build Coastguard Worker 238*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: 239*89a0ef05SAndroid Build Coastguard Worker 240*89a0ef05SAndroid Build Coastguard Worker```sh 241*89a0ef05SAndroid Build Coastguard Workersudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu 242*89a0ef05SAndroid Build Coastguard Worker``` 243*89a0ef05SAndroid Build Coastguard Worker 244*89a0ef05SAndroid Build Coastguard WorkerCompile: 245*89a0ef05SAndroid Build Coastguard Worker 246*89a0ef05SAndroid Build Coastguard Worker```sh 247*89a0ef05SAndroid Build Coastguard Workercmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64-linux-gnu.cmake -DUHDR_BUILD_DEPS=1 ../ 248*89a0ef05SAndroid Build Coastguard Workerninja 249*89a0ef05SAndroid Build Coastguard Worker``` 250*89a0ef05SAndroid Build Coastguard Worker 251*89a0ef05SAndroid Build Coastguard Worker#### Target - Linux Platform - RISC-V Arch (64 bit) 252*89a0ef05SAndroid Build Coastguard Worker 253*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: 254*89a0ef05SAndroid Build Coastguard Worker 255*89a0ef05SAndroid Build Coastguard Worker```sh 256*89a0ef05SAndroid Build Coastguard Workersudo apt install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu 257*89a0ef05SAndroid Build Coastguard Worker``` 258*89a0ef05SAndroid Build Coastguard Worker 259*89a0ef05SAndroid Build Coastguard WorkerCompile: 260*89a0ef05SAndroid Build Coastguard Worker 261*89a0ef05SAndroid Build Coastguard Worker```sh 262*89a0ef05SAndroid Build Coastguard Workercmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/riscv64-linux-gnu.cmake -DUHDR_BUILD_DEPS=1 ../ 263*89a0ef05SAndroid Build Coastguard Workerninja 264*89a0ef05SAndroid Build Coastguard Worker``` 265*89a0ef05SAndroid Build Coastguard Worker 266*89a0ef05SAndroid Build Coastguard WorkerThis will generate the following files under `build_directory`: 267*89a0ef05SAndroid Build Coastguard Worker 268*89a0ef05SAndroid Build Coastguard Worker**libuhdr.so.{version}** - Shared library for the libuhdr API <br> 269*89a0ef05SAndroid Build Coastguard Worker**libuhdr.so** - Symlink to shared library <br> 270*89a0ef05SAndroid Build Coastguard Worker**libuhdr.a** - Static link library for the libuhdr API <br> 271*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_app** - sample application <br> 272*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_unit_test** - unit tests <br> 273*89a0ef05SAndroid Build Coastguard Worker 274*89a0ef05SAndroid Build Coastguard Worker#### Target - Linux Platform - RISC-V Arch (32 bit) 275*89a0ef05SAndroid Build Coastguard Worker 276*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: 277*89a0ef05SAndroid Build Coastguard Worker 278*89a0ef05SAndroid Build Coastguard Worker```sh 279*89a0ef05SAndroid Build Coastguard Worker# Download from https://github.com/riscv-collab/riscv-gnu-toolchain/releases 280*89a0ef05SAndroid Build Coastguard Workersudo ln -s {your_dir}/riscv/bin/riscv32-unknown-linux-gnu-g++ /usr/bin/riscv32-linux-gnu-g++ 281*89a0ef05SAndroid Build Coastguard Workersudo ln -s {your_dir}/riscv/bin/riscv32-unknown-linux-gnu-gcc /usr/bin/riscv32-linux-gnu-gcc 282*89a0ef05SAndroid Build Coastguard Worker``` 283*89a0ef05SAndroid Build Coastguard Worker 284*89a0ef05SAndroid Build Coastguard WorkerCompile: 285*89a0ef05SAndroid Build Coastguard Worker 286*89a0ef05SAndroid Build Coastguard Worker```sh 287*89a0ef05SAndroid Build Coastguard Workercmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/riscv32-linux-gnu.cmake -DUHDR_BUILD_DEPS=1 ../ 288*89a0ef05SAndroid Build Coastguard Workerninja 289*89a0ef05SAndroid Build Coastguard Worker``` 290*89a0ef05SAndroid Build Coastguard Worker 291*89a0ef05SAndroid Build Coastguard WorkerThis will generate the following files under `build_directory`: 292*89a0ef05SAndroid Build Coastguard Worker 293*89a0ef05SAndroid Build Coastguard Worker**libuhdr.so.{version}** - Shared library for the libuhdr API <br> 294*89a0ef05SAndroid Build Coastguard Worker**libuhdr.so** - Symlink to shared library <br> 295*89a0ef05SAndroid Build Coastguard Worker**libuhdr.a** - Static link library for the libuhdr API <br> 296*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_app** - sample application <br> 297*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_unit_test** - unit tests <br> 298*89a0ef05SAndroid Build Coastguard Worker 299*89a0ef05SAndroid Build Coastguard Worker#### Target - Linux Platform - LOONG Arch (64 bit) 300*89a0ef05SAndroid Build Coastguard Worker 301*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: 302*89a0ef05SAndroid Build Coastguard Worker 303*89a0ef05SAndroid Build Coastguard Worker```sh 304*89a0ef05SAndroid Build Coastguard Workersudo apt install gcc-loongarch64-linux-gnu g++-loongarch64-linux-gnu 305*89a0ef05SAndroid Build Coastguard Worker``` 306*89a0ef05SAndroid Build Coastguard Worker 307*89a0ef05SAndroid Build Coastguard WorkerCompile: 308*89a0ef05SAndroid Build Coastguard Worker 309*89a0ef05SAndroid Build Coastguard Worker```sh 310*89a0ef05SAndroid Build Coastguard Workercmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/loong64-linux-gnu.cmake -DUHDR_BUILD_DEPS=1 ../ 311*89a0ef05SAndroid Build Coastguard Workerninja 312*89a0ef05SAndroid Build Coastguard Worker``` 313*89a0ef05SAndroid Build Coastguard Worker 314*89a0ef05SAndroid Build Coastguard Worker#### Target - Android Platform 315*89a0ef05SAndroid Build Coastguard Worker 316*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: 317*89a0ef05SAndroid Build Coastguard Worker 318*89a0ef05SAndroid Build Coastguard Worker```sh 319*89a0ef05SAndroid Build Coastguard Workerwget https://dl.google.com/android/repository/android-ndk-r26d-linux.zip 320*89a0ef05SAndroid Build Coastguard Workerunzip android-ndk-r26d-linux.zip 321*89a0ef05SAndroid Build Coastguard Worker``` 322*89a0ef05SAndroid Build Coastguard Worker 323*89a0ef05SAndroid Build Coastguard WorkerChoose target architecture with -DANDROID_ABI={armeabi-v7a, arm64-v8a, x86, x86_64} 324*89a0ef05SAndroid Build Coastguard Worker 325*89a0ef05SAndroid Build Coastguard WorkerCompile: 326*89a0ef05SAndroid Build Coastguard Worker```sh 327*89a0ef05SAndroid Build Coastguard Workercmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/android.cmake -DUHDR_ANDROID_NDK_PATH=/opt/android-ndk-r26d/ -DUHDR_BUILD_DEPS=1 -DANDROID_ABI="Selected Architecture" -DANDROID_PLATFORM=android-23 ../ 328*89a0ef05SAndroid Build Coastguard Workerninja 329*89a0ef05SAndroid Build Coastguard Worker``` 330*89a0ef05SAndroid Build Coastguard Worker 331*89a0ef05SAndroid Build Coastguard WorkerThis will generate the following files under `build_directory`: 332*89a0ef05SAndroid Build Coastguard Worker 333*89a0ef05SAndroid Build Coastguard Worker**libuhdr.so** - Shared library for the libuhdr API <br> 334*89a0ef05SAndroid Build Coastguard Worker**libuhdr.a** - Static link library for the libuhdr API <br> 335*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_app** - sample application <br> 336*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_unit_test** - unit tests <br> 337*89a0ef05SAndroid Build Coastguard Worker 338*89a0ef05SAndroid Build Coastguard Worker#### Target - Wasm 339*89a0ef05SAndroid Build Coastguard Worker 340*89a0ef05SAndroid Build Coastguard WorkerInstall the prerequisite packages before building: Follow the instructions given [here](https://emscripten.org/docs/getting_started/downloads.html#installation-instructions-using-the-emsdk-recommended). 341*89a0ef05SAndroid Build Coastguard Worker 342*89a0ef05SAndroid Build Coastguard WorkerCompile: 343*89a0ef05SAndroid Build Coastguard Worker```sh 344*89a0ef05SAndroid Build Coastguard Workeremcmake cmake -G Ninja ../ 345*89a0ef05SAndroid Build Coastguard Workerninja 346*89a0ef05SAndroid Build Coastguard Worker``` 347*89a0ef05SAndroid Build Coastguard Worker 348*89a0ef05SAndroid Build Coastguard WorkerThis will generate the following files under `build_directory`: 349*89a0ef05SAndroid Build Coastguard Worker 350*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_app.wasm** - wasm module <br> 351*89a0ef05SAndroid Build Coastguard Worker**ultrahdr_app.js** - sample application <br> 352*89a0ef05SAndroid Build Coastguard Worker 353*89a0ef05SAndroid Build Coastguard Worker## Building Fuzzers 354*89a0ef05SAndroid Build Coastguard Worker 355*89a0ef05SAndroid Build Coastguard WorkerRefer to [fuzzers.md](fuzzers.md) for complete instructions. 356