Cross-Compilation from docker container

DRIVE OS Version: 6.0.10

Issue Description: Simple app cross-compilation from a docker container to the AGX Orin.

Hello all,

I have a docker container with the DriveOS 6.0.10 installed on a x86 machine and a AGX Orin DriveKit.

I have build a small cpp code that sets up a GMSL camera and is going to send the stream to a QT app, ROS 2 node, or whatever I need. Using the driveworks libraries like dw/sensors/camera/Camera.h, Sensors.h, etc.

I want to cross-compile this simple code in my x86 docker container and copy it to my AGX Orin DriveKit, using a command like:

/drive/toolchains/aarch64--glibc--stable-2022.03-1/bin/aarch64-linux-g++ main.cpp -o camera \
--sysroot=/drive/toolchains/aarch64--glibc--stable-2022.03-1/aarch64-buildroot-linux-gnu/sysroot \
-I/drive/drive-linux/filesystem/targetfs/usr/local/driveworks/include \
-I/drive/drive-linux/filesystem/targetfs/usr/local/driveworks/targets/aarch64-Linux/include \
-I/drive/drive-linux/filesystem/targetfs/usr/include \
-I/drive/drive-linux/filesystem/targetfs/usr/local/cuda/include \
-L/drive/drive-linux/filesystem/targetfs/usr/local/driveworks/targets/aarch64-Linux/lib \
-L/drive/drive-linux/filesystem/targetfs/usr/local/cuda/targets/aarch64-linux/lib \
-ldriveworks -lcudart -std=c++14

But all I get is /drive/toolchains/aarch64--glibc--stable-2022.03-1/bin/../lib/gcc/aarch64-buildroot-linux-gnu/9.3.0/../../../../aarch64-buildroot-linux-gnu/bin
/ld: cannot find -ldriveworks

I have tried finding libdriveworks.* but that file seems to not be present in the system. Libcudart.* is present in /drive/drive-linux/filesystem/targetfs/usr/local/cuda/targets/aarch64-linux/lib/libcudart.so.

I believe I have all the cross-compile tools installed as the docker image was build with all options selected.

It is also possible (and likely) that I am not doing this correctly.

Any help will be greatly appreciated!

Turns out I was doing it incorrectly and I have since made a simple cmake to cross compile, however when transfered to my drivekit from the docker, it seg faults straight away.

The main code simply prints something on the screen:
#include <dw/core/context/Context.h>
#include <dw/core/base/Version.h>
#include <iostream>

int main() {
dwContextHandle_t context = DW_NULL_HANDLE;
dwContextParameters params{};
dwStatus status = dwInitialize(&context, DW_VERSION, &params);

if (status != DW_SUCCESS) {
std::cout << "dwInitialize failed: " << status << std::endl;
return -1;
}

dwVersion version{};
dwGetVersion(&version);

std::cout << "Hello DriveWorks "
<< version.major << "."
<< version.minor << "."
<< version.patch << std::endl;

dwRelease(context);
return 0;
}

Toolchain.cmake:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_SYSROOT /drive/drive-linux/filesystem/targetfs)

set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++)

set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})

set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)

project(main)

set(CMAKE_CXX_STANDARD 14)
set(TARGETFS /drive/drive-linux/filesystem/targetfs)
set(DRIVEWORKS ${TARGETFS}/usr/local/driveworks)
set(CUDA ${TARGETFS}/usr/local/cuda-11.4)

include_directories(
${DRIVEWORKS}/include
${CUDA}/targets/aarch64-linux/include
${TARGETFS}/usr/include
)

link_directories(
${DRIVEWORKS}/targets/aarch64-Linux/lib
${CUDA}/targets/aarch64-linux/lib
)

add_executable(main main.cpp)

target_link_libraries(main
dw_base
cudart
cuda
cudla
)

Dear @p.ramos ,
Could you include this code in directory and keep it inside as a DW sample directory and make changes in DW make file to include your directory. This helps to build your sample along with DW sample with out any issue. Could you check that ?

Dear @SivaRamaKrishnaNV,

Thank you, that did work!

I was suspecting the code itself to be fault but must be the cmake config. Is there a base cmake config or a tutorial for building and compiling smaller Cpp scripts available? If not I will adapt the sample ones.

Dear @p.ramos ,
You can copy any DW sample folder config file and use it for your sample.