Cross-Compilation Failure While Adding External Libraries to The radar_replay Example

Hello,

I am trying to compile the radar_replay example in Nsight by including external libraries. I have correctly updated all the related CMAKE files in the project and host compilation can be done without any issue. However when I am trying to use the target build configuration to compile the example, the following errors are encountered. Could you please help me with this issue?

Nsight Console Content:

12:43:34 **** Incremental Build of configuration build-target for project DriveNet ****
make all
[ 0%] Built target update_cuda_deps
[ 26%] Built target dw_samples_framework
[ 29%] Built target sample_sensors_info
[ 33%] Built target sample_gps_logger
[ 36%] Built target sample_imu_logger
[ 40%] Built target sample_camera_replay
[ 43%] Built target sample_camera_seek
[ 47%] Built target sample_camera_multiple_replay
[ 52%] Built target sample_camera_usb
[ 57%] Built target sample_camera_pointgrey
[ 61%] Built target sample_record
[ 64%] Built target sample_canbus_logger
[ 70%] Built target sample_canbus_interpreter
[ 75%] Built target sample_lidar_replay
[ 77%] Building CXX object src/sensors/radar/radar_replay/CMakeFiles/sample_radar_replay.dir/main.cpp.o
In file included from /home/conti/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/X11/Xlib.h:44:0,
from /home/conti/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/eglplatform.h:119,
from /home/conti/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/egl.h:39,
from /usr/local/driveworks-0.6/targets/aarch64-linux/include/dw/core/EGL.h:49,
from /usr/local/driveworks-0.6/samples-nsight/src/framework/../framework/Window.hpp:34,
from /usr/local/driveworks-0.6/samples-nsight/src/framework/../framework/DriveWorksSample.hpp:41,
from /usr/local/driveworks-0.6/samples-nsight/src/sensors/radar/radar_replay/main.cpp:31:
/usr/local/install/ecal-4.9.4/ecal/include/ecal/ecal_init.h:45:31: error: expected unqualified-id before numeric constant
static const unsigned int None = 0x000;
^
In file included from /home/conti/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/eglplatform.h:119:0,
from /home/conti/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/egl.h:39,
from /usr/local/driveworks-0.6/targets/aarch64-linux/include/dw/core/EGL.h:49,
from /usr/local/driveworks-0.6/samples-nsight/src/framework/../framework/Window.hpp:34,
from /usr/local/driveworks-0.6/samples-nsight/src/framework/../framework/DriveWorksSample.hpp:41,
from /usr/local/driveworks-0.6/samples-nsight/src/sensors/radar/radar_replay/main.cpp:31:
/usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/logging.h:66:7: error: expected identifier before 'int'
class Status;
^
/usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/logging.h:66:7: error: multiple types in one declaration
In file included from /usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/common.h:50:0,
from /usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/descriptor.pb.h:9,
from /usr/local/install/ecal-4.9.4/contrib/ecal_proto/include/ecal/protobuf/ecal_proto_hlp.h:24,
from /usr/local/install/ecal-4.9.4/ecal/include/ecal/msg/proto.h:16,
from /usr/local/driveworks-0.6/samples-nsight/src/sensors/radar/radar_replay/main.cpp:70:
/usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/logging.h:90:32: error: expected ')' before '::' token
LogMessage& operator<^
/usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/logging.h:90:32: error: 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator</usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/logging.h:90:26: error: expected ';' at end of member declaration
LogMessage& operator<^
In file included from /home/conti/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/eglplatform.h:119:0,
from /home/conti/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/egl.h:39,
from /usr/local/driveworks-0.6/targets/aarch64-linux/include/dw/core/EGL.h:49,
from /usr/local/driveworks-0.6/samples-nsight/src/framework/../framework/Window.hpp:34,
from /usr/local/driveworks-0.6/samples-nsight/src/framework/../framework/DriveWorksSample.hpp:41,
from /usr/local/driveworks-0.6/samples-nsight/src/sensors/radar/radar_replay/main.cpp:31:
/usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/logging.h:90:58: error: expected unqualified-id before 'int'
LogMessage& operator<^
make[2]: *** [src/sensors/radar/radar_replay/CMakeFiles/sample_radar_replay.dir/main.cpp.o] Error 1
src/sensors/radar/radar_replay/CMakeFiles/sample_radar_replay.dir/build.make:62: recipe for target 'src/sensors/radar/radar_replay/CMakeFiles/sample_radar_replay.dir/main.cpp.o' failed
make[1]: *** [src/sensors/radar/radar_replay/CMakeFiles/sample_radar_replay.dir/all] Error 2
make: *** [all] Error 2
CMakeFiles/Makefile2:938: recipe for target 'src/sensors/radar/radar_replay/CMakeFiles/sample_radar_replay.dir/all' failed
Makefile:127: recipe for target 'all' failed

12:43:36 Build Finished (took 1s.714ms)

Toolchain-V4L.cmake

# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.

set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION 1)
set(VIBRANTE_BUILD ON) #flags for the CMakeList.txt
set(CMAKE_SYSTEM_PROCESSOR aarch64)

# need that one here, because this is a toolchain file and hence executed before
# default cmake settings are set
set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so")

# check that Vibrante PDK must be set
if(NOT DEFINED VIBRANTE_PDK)
if(DEFINED ENV{VIBRANTE_PDK})
message(STATUS "VIBRANTE_PDK = ENV : $ENV{VIBRANTE_PDK}")
set(VIBRANTE_PDK $ENV{VIBRANTE_PDK} CACHE STRING "Path to the vibrante-XXX-linux path for cross-compilation" FORCE)
endif()
else()
message(STATUS "VIBRANTE_PDK = ${VIBRANTE_PDK}")
endif()

if(DEFINED VIBRANTE_PDK)
if(NOT IS_ABSOLUTE ${VIBRANTE_PDK})
get_filename_component(VIBRANTE_PDK "${SDK_BINARY_DIR}/${VIBRANTE_PDK}" ABSOLUTE)
endif()
endif()

set(ARCH "aarch64")
set(VIBRANTE TRUE)
set(VIBRANTE_V5L TRUE)
add_definitions(-DVIBRANTE -DVIBRANTE_V5L)

set(TOOLCHAIN "${VIBRANTE_PDK}/../toolchains/tegra-4.9-nv")

set(CMAKE_CXX_COMPILER "${TOOLCHAIN}/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-g++")
set(CMAKE_C_COMPILER "${TOOLCHAIN}/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gcc")
set(GCC_COMPILER_VERSION "4.9" CACHE STRING "GCC Compiler version")

# setup compiler for cross-compilation
set(CMAKE_CXX_FLAGS "-fPIC" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS "-fPIC" CACHE STRING "c flags")
set(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags")
set(CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags")
set(CMAKE_EXE_LINKER_FLAGS "" CACHE STRING "executable linker flags")

set(LD_PATH ${VIBRANTE_PDK}/lib-target)
set(LD_PATH_EXTRA ${VIBRANTE_PDK}/targetfs/lib/aarch64-linux-gnu)

# Please, be carefull looks like "-Wl,-unresolved-symbols=ignore-in-shared-libs" can lead to silent "ld" problems
set(CMAKE_SHARED_LINKER_FLAGS "-L${LD_PATH} -L${LD_PATH_EXTRA} -Wl,-rpath,${LD_PATH} ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-L${LD_PATH} -L${LD_PATH_EXTRA} -Wl,-rpath,${LD_PATH} ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-L${LD_PATH} -L${LD_PATH_EXTRA} -Wl,-rpath,${LD_PATH} ${CMAKE_EXE_LINKER_FLAGS}")

# Set cmake root path. If there is no "/usr/local" in CMAKE_FIND_ROOT_PATH then FinCUDA.cmake doesn't work
set(CMAKE_FIND_ROOT_PATH ${VIBRANTE_PDK} ${VIBRANTE_PDK}/targetfs/usr/local/ ${VIBRANTE_PDK}/targetfs/ /usr/local)

# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# set system default include dir
include_directories(BEFORE SYSTEM ${VIBRANTE_PDK}/include
/usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include
/usr/local/install/ecal-4.9.4/ecal/include
/usr/local/install/ecal-4.9.4/contrib/ecal_proto/include
)

#/usr/local/install/ecal-4.9.4/ecal/include
#/usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include

# determine target device and pdk branch
if(NOT DEFINED VIBRANTE_PDK_DEVICE AND VIBRANTE_PDK)
if(${VIBRANTE_PDK} MATCHES "(vibrante|drive)-(t.+)-linux$")
set(VIBRANTE_PDK_DEVICE ${CMAKE_MATCH_2} CACHE STRING "Cross-compilation target device")
message(STATUS "VIBRANTE_PDK_DEVICE = ${VIBRANTE_PDK_DEVICE}")
else()
message(FATAL_ERROR "Can't determine target device for PDK: ${VIBRANTE_PDK}")
endif()
endif()

if(NOT DEFINED VIBRANTE_PDK_BRANCH AND VIBRANTE_PDK)
if(EXISTS "${VIBRANTE_PDK}/lib-target/version-nv-pdk.txt")
set(VIBRANTE_PDK_FILE "${VIBRANTE_PDK}/lib-target/version-nv-pdk.txt")
elseif(EXISTS "${VIBRANTE_PDK}/lib-target/version-nv-sdk.txt")
set(VIBRANTE_PDK_FILE "${VIBRANTE_PDK}/lib-target/version-nv-sdk.txt")
endif()

if(VIBRANTE_PDK_FILE)
file(READ ${VIBRANTE_PDK_FILE} version-nv-pdk)
if(${version-nv-pdk} MATCHES "^(.+)-[0123456789]+")
set(VIBRANTE_PDK_BRANCH ${CMAKE_MATCH_1} CACHE STRING "Cross-compilation PDK branch name")
message(STATUS "VIBRANTE_PDK_BRANCH = ${VIBRANTE_PDK_BRANCH}")
else()
message(FATAL_ERROR "Can't determine PDK branch for PDK ${VIBRANTE_PDK}")
endif()
else()
message(FATAL_ERROR "Can't open ${VIBRANTE_PDK}/lib-target/version-nv-(pdk/sdk).txt for PDK branch detection")
endif()
endif()

if(DEFINED VIBRANTE_PDK_BRANCH)
string(REPLACE "." ";" PDK_VERSION_LIST ${VIBRANTE_PDK_BRANCH})

# Some PDK's have less than three version numbers. Pad the list so we always
# have at least three numbers, allowing pre-existing logic depending on major,
# minor, patch versioning to work without modifications
list(LENGTH PDK_VERSION_LIST _PDK_VERSION_LIST_LENGTH)
while(_PDK_VERSION_LIST_LENGTH LESS 3)
list(APPEND PDK_VERSION_LIST 0)
math(EXPR _PDK_VERSION_LIST_LENGTH "${_PDK_VERSION_LIST_LENGTH} + 1")
endwhile()

set(VIBRANTE_PDK_PATCH 0)
set(VIBRANTE_PDK_BUILD 0)

list(LENGTH PDK_VERSION_LIST PDK_VERSION_LIST_LENGTH)

list(GET PDK_VERSION_LIST 0 VIBRANTE_PDK_MAJOR)
list(GET PDK_VERSION_LIST 1 VIBRANTE_PDK_MINOR)
if(PDK_VERSION_LIST_LENGTH GREATER 2)
list(GET PDK_VERSION_LIST 2 VIBRANTE_PDK_PATCH)
endif()

if(PDK_VERSION_LIST_LENGTH GREATER 3)
list(GET PDK_VERSION_LIST 3 VIBRANTE_PDK_BUILD)
endif()

set(VIBRANTE_PDK_VERSION ${VIBRANTE_PDK_MAJOR}.${VIBRANTE_PDK_MINOR}.${VIBRANTE_PDK_PATCH}.${VIBRANTE_PDK_BUILD})

add_definitions(-DVIBRANTE_PDK_VERSION=\"${VIBRANTE_PDK_VERSION}\") # requires escaping so it is treated as a string
# and not an invalid floating point with too many decimal points
add_definitions(-DVIBRANTE_PDK_MAJOR=${VIBRANTE_PDK_MAJOR})
add_definitions(-DVIBRANTE_PDK_MINOR=${VIBRANTE_PDK_MINOR})
add_definitions(-DVIBRANTE_PDK_PATCH=${VIBRANTE_PDK_PATCH})
add_definitions(-DVIBRANTE_PDK_BUILD=${VIBRANTE_PDK_BUILD})
message(STATUS "Vibrante version ${VIBRANTE_PDK_VERSION}")
endif()

Dear sina.davani,

I’m not sure what I missed.
However according to the log, it seems like there are some missing point in your code.

/usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/logging.h:90:32: error: expected ')' before '::' token
LogMessage& operator<^
/usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/logging.h:90:32: error: 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator</usr/local/install/ctzs_dependencies-eCAL_v4.9.4/libprotobuf3/include/google/protobuf/stubs/logging.h:90:26: error: expected ';' at end of member declaration
LogMessage& operator<^

Thank you very much for your reply. The code here is actually from Google protobuf. We have been informed that the problem is the difference in toolchains between our included library (gcc 5) and NVIDIA Driveworks (gcc 4.9).