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:
- 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.
- 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
- Install CMake (See Note 2 above)
- Ubuntu 22.04 ships with CMake 3.22.1
- Open a command terminal window
- Go to the
org.openjaus.sae-sdk.cpp
foldercd {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}
- The path that contains the unzipped
- Create a
build
folder to house the CMake generated build files. This keeps the source and build files separatedmkdir build
- Go into the newly created build folder
cd build
-
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 theCMAKE_INSTALL_PREFIX
CMake variable when running the initial cmake commandcmake -DOJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON -DCMAKE_INSTALL_PREFIX={my_install_location} ..
- This will use the default CMake generator which is
-
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
- If you have multi-core CPU you can have
- Install the header files and built binaries
make install
For Windows
- Install CMake (See Note 2 above)
- Open a command terminal window
- 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}
- The path that contains the unzipped
- cd
- Create a build folder to house the CMake generated build files. This keeps the source and build files separated
mkdir build
- Go into the newly created build folder
cd build
-
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 theCMAKE_INSTALL_PREFIX
CMake variable when running the initial cmake commandcmake -DOJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON -DCMAKE_INSTALL_PREFIX={my_install_location} ..
- 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
-
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 ..
-
- By default the headers and libraries will be installed automatically after the build to install location configured.
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
- 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
- Verify you can run
- For running on Ubuntu 18.04:
- Install CMake if necessary
- Open a command terminal window
- 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}
- The path that contains the unzipped
- cd
- Create a build folder to house the CMake generated build files. This keeps the source and build files separated
mkdir build
- Go into the newly created build folder
cd build
- Copy the cross-compile toolchain file to the build folder
cp ../org.openjaus.buildtools.cmake/toolchains/linaro_gcc7.cmake .
-
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 theCMAKE_INSTALL_PREFIX
CMake variable when running the initial cmake commandcmake -D OJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON -D CMAKE_INSTALL_PREFIX={my_install_location} ..
- This will use the default CMake generator which is
-
Build
cmake --build .
- 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.
- By default the compiled application(s) will be installed to
Using a Windows Host
- 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
- Verify you can run
- 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
- Verify you can run
- For running on Ubuntu 18.04:
- Open a command terminal window
- Go to the
org.openjaus.sae-sdk.cpp
foldercd {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}
- The path that contains the unzipped
- Create a
build
folder to house the CMake generated build files. This keeps the source and build files separatedmkdir build
- Go into the newly created build folder
cd build
- 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
- 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
- Build
cmake --build .
- 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
- By default the compiled application(s) will be installed to