Skip to content

Compilation and Installation

CMake is used to create the necessary build files (Unix Makefiles on Linux, MS Visual Studio Solutions on Windows, etc) for compiling the OpenJAUS SDK source code.

Important Notes:

  1. We make a number of assumptions on how the average user will be building/using our code base, in order to make Getting Started as simple as possible. If you have more complex needs, you may need to modify the CMakeLists.txt files directly or set cmake variables to modify our default behavior.
  2. The provided CMake files were tested using CMake v3.22. They should work with CMake v3.14 or later but this has not been verified.

Compiling the Code

Building the SDK will build the OpenJAUS libraries and the Examples.

For Linux

  1. Install CMake (See Note 2 above)
    • Ubuntu 22.04 ships with CMake 3.22.1
  2. Open a command terminal window
  3. Go to the org.openjaus.sae-sdk.cpp folder
    • cd {sdk_parent}/org.openjaus.sae-sdk.cpp
      • The path that contains the unzipped org.openjaus.sae-sdk.cpp folder will be referred to as {sdk_parent}
  4. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  5. Go into the newly created build folder
    • cd build
  6. Run CMake from within the build folder and have it point to the directory that contains the CMakeLists.txt file

    • cmake ..
      • This will use the default CMake generator which is Unix Makefiles on Linux. If you want to use a different generator you will need to specify as such using CMake's -G option.
      • By default the headers and libraries will be installed to {sdk_parent}/install/{OS_Architecture} vs CMake's default location (/usr/local/).
        • This removes the need to have root access to do the install and keeps the openjaus files isolated for easier removal later.
        • If you want to use CMake's default location then set the OJ_USE_DEFAULT_INSTALL_DIR=OFF
          • cmake -DOJ_USE_DEFAULT_INSTALL_DIR=OFF ..
        • If you want to install to a custom location set OJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON and use the CMAKE_INSTALL_PREFIX CMake variable when running the initial cmake command
          • cmake -DOJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON -DCMAKE_INSTALL_PREFIX={my_install_location} ..
  7. Run make to build the code

    • make all
      • If you have multi-core CPU you can have make split the build across multiple "jobs".
      • For example, to use 4 jobs for the compile:
        • make -j4 all
  8. Install the header files and built binaries
    • make install

For Windows

  1. Install CMake (See Note 2 above)
  2. Open a command terminal window
  3. Go to the org.openjaus.sdk.cpp folder
    • cd {sdk_parent}/org.openjaus.sdk.cpp
      • The path that contains the unzipped org.openjaus.sae-sdk.cpp folder will be referred to as {sdk_parent}
  4. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  5. Go into the newly created build folder
    • cd build
  6. Run CMake from within the build folder and have it point to the directory that contains the CMakeLists.txt file

    • cmake ..
      • This will use the default CMake generator which is typically Visual Studio Project/Solution on Windows. If you want to use a different generator you will need to specify as such using CMake's -G option.
      • By default the headers and libraries will be installed to {sdk_parent}/install/{OS_Architecture} vs CMake's default location (c:/Program Files/${PROJECT_NAME}).
        • This removes the need to have Administrator access to do the install.
        • If you want to use CMake's default location then set the OJ_USE_DEFAULT_INSTALL_DIR=OFF
          • cmake -DOJ_USE_DEFAULT_INSTALL_DIR=OFF ..
        • If you want to install to a custom location set OJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON and use the CMAKE_INSTALL_PREFIX CMake variable when running the initial cmake command
          • cmake -DOJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON -DCMAKE_INSTALL_PREFIX={my_install_location} ..
  7. Open generated solution in MS Visual Studio and build

    • By default the headers and libraries will be installed automatically after the build to install location configured.
      • This removes the need to run the install manually.
      • If you the install location is configured to the default then Visual Studio will need to have administrator access to do the install.
    • If you don't want the install to run automatically set CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD=OFF when running CMake
        • cmake -DCMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD=OFF ..

Cross-Compiling for ARM Linux

Note: The instructions are slightly different depending in the version of the linux that the code is intended to run against. Basically, the compiler version being used to cross-compile must match the version provided on the board.

Using a Linux Host

  1. Install the ARM GNU Toolchain
    • For running on Ubuntu 18.04:
      • Download the Linary gcc7 toolchain
      • Unzip the archive
      • Add {install location}/bin to the path
        • Verify you can run aarch64-none-linux-gnu-g++ --version
  2. Install CMake if necessary
  3. Open a command terminal window
  4. Go to the org.openjaus.sae-sdk.cpp folder
    • cd {sdk_parent}/org.openjaus.sae-sdk.cpp
      • The path that contains the unzipped org.openjaus.sae-sdk.cpp folder will be referred to as {sdk_parent}
  5. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  6. Go into the newly created build folder
    • cd build
  7. Copy the cross-compile toolchain file to the build folder
    • cp ../org.openjaus.buildtools.cmake/toolchains/linaro_gcc7.cmake .
  8. Run cmake using the toolchain file

    • cmake -D CMAKE_TOOLCHAIN_FILE=linaro_gcc7.cmake ..
      • This will use the default CMake generator which is Unix Makefiles on Linux. If you want to use a different generator you will need to specify as such using CMake's -G option.
      • By default the headers and libraries will be installed to {sdk_parent}/install/{OS_Architecture} vs CMake's default location (/usr/local/).
        • This removes the need to have root access to do the install and keeps the openjaus files isolated for easier removal later.
        • If you want to use CMake's default location then set the OJ_USE_DEFAULT_INSTALL_DIR=OFF
          • cmake -D OJ_USE_DEFAULT_INSTALL_DIR=OFF ..
        • If you want to install to a custom location set OJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON and use the CMAKE_INSTALL_PREFIX CMake variable when running the initial cmake command
          • cmake -D OJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON -D CMAKE_INSTALL_PREFIX={my_install_location} ..
  9. Build

    • cmake --build .
  10. Install
    • cmake --install .
      • By default the compiled application(s) will be installed to {sdk_parent}/install/{OS_Architecture} vs cmake's default location (/usr/local). This removes the need to have root access to do the install.

Using a Windows Host

  1. Install MinGW-w64
    • Go to winlibs.com
    • Download the appropriate UCRT runtime archive
      • GCC 12.2.0 + LLVM/Clang/LLD/LLDB 15.0.6 + MinGW-w64 10.0.0 (UCRT) - release 3
    • Unzip mingw64 folder
    • Add {ming64 location}/bin to the path
      • Verify you can run mingw32-make --version
  2. Install the Arm GNU Toolchain
    • For running on Ubuntu 18.04:
      • Download the Linaro gcc7 toolchain
      • Unzip the archive (7-Zip)
      • Add {install location}/bin to the path
        • Verify you can run aarch64-none-linux-gnu-g++ --version
  3. Open a command terminal window
  4. Go to the org.openjaus.sae-sdk.cpp folder
    • cd {sdk_parent}/org.openjaus.sae-sdk.cpp
      • The path that contains the unzipped org.openjaus.sae-sdk.cpp folder will be referred to as {sdk_parent}
  5. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  6. Go into the newly created build folder
    • cd build
  7. Copy the cross-compile toolchain file to the build folder
    • cp ../org.openjaus.buildtools.cmake/toolchains/linaro_gcc7.cmake .
      • cp is the command to copy files when using PowerShell. If you're using Windows Command Prompt, the command will be different
  8. Run cmake using the toolchain file
    • cmake -G “MinGW Makefiles” -D CMAKE_TOOLCHAIN_FILE=linaro_gcc7.cmake ..
      • Cross-compiling requires the generation of MinGW Makefiles versus Microsoft Visual Studio files
  9. Build
    • cmake --build .
  10. Install
    • cmake --install .
      • By default the compiled application(s) will be installed to {openjaus_sdk_root}/install/{OS_Architecture} vs cmake's default location. This removes the need to have root access to do the install