Cross-compiling - Issue with linking header files

I started working in the PX2 since the last week. I have been going through the tutorials for cross-compilation. I wrote a basic code on the px2 including the driveworks apis which retrieve the sdkversion and print it. This is just to get a hands-on with the system. It worked fine, next thing i wanted to compile this code on a host machine: here my laptop. But the compilation doesnt happen.

CMakeFiles/hello_world.dir/main.cpp.o: In function `main':
main.cpp:(.text.startup+0x14): undefined reference to `dwGetVersion'
collect2: error: ld returned 1 exit status
src/hello_world/CMakeFiles/hello_world.dir/build.make:94: recipe for target 'src/hello_world/hello_world' failed
make[2]: *** [src/hello_world/hello_world] Error 1
CMakeFiles/Makefile2:300: recipe for target 'src/hello_world/CMakeFiles/hello_world.dir/all' failed
make[1]: *** [src/hello_world/CMakeFiles/hello_world.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

I tried to compile this code by gcc compiler and got to know that is is not able to find the directories.

In file included from main.cpp:3:0:
/usr/local/driveworks/include/dw/Driveworks.h:42:29: fatal error: 
dw/core/Exports.h: No such file or directory
compilation terminated.

I have included only the Driveworks.h header file which is properly recognised, but any header files included inside it remain unrecognised.

Dear @sanjay.varghese,
Firstly, Could you cross compiling the shipped driveworks samples? Do you see any issue? Please check sample cross compilation in DW documentation.

if it works, make sure you create you project as a sample in DW and update the CMakefiles accordingly and try checking cross compiling again.

This works with ease. i was having issues with this previously, but this is solved and i was successful in running a compiled bin file from my host to px2

Dear @sanjay.varghese,
It is not clear what you are asking. Could you check the following and confirm

  1. First check compiling/cross compilng the shipped samples on host and make sure it works. If you see any issues, let us know.
  2. If the above is successful, add your code as a DW sample and update the CMakefiles accordingly and check compiling/cross compiling. If you see any issue, please attach the sample and Cmakefiles for review.

I copied the hello_world sample provided in the samples folder to my project src folder. Then i tried make, i am getting an error.
[ 0%] Built target update_cuda_deps [ 15%] Linking CXX executable sample_hello_world [ 15%] Built target lodepng-src [ 95%] Built target glfw /home/sanjay-jayashankar/nvidia/nvidia_sdk/DRIVE/Linux/5.0.13.0/OS/DriveSDK/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/../../libexec/aarch64-gnu-linux/gcc/aarch64-gnu-linux/4.9.4/ld: cannot find -ldw_samples_framework collect2: error: ld returned 1 exit status src/hello_world/CMakeFiles/sample_hello_world.dir/build.make:104: recipe for target 'src/hello_world/sample_hello_world' failed make[2]: *** [src/hello_world/sample_hello_world] Error 1 CMakeFiles/Makefile2:300: recipe for target 'src/hello_world/CMakeFiles/sample_hello_world.dir/all' failed make[1]: *** [src/hello_world/CMakeFiles/sample_hello_world.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2

Dear @sanjay.varghese,
Please confirm what all worked w.r.t my above comment. You said you are trying to compile for the host. But the log indicates your trying to cross compile sample.
Could you please check the below steps.

  • create your project as a sample inside /usr/local/driveworks/samples/src similar to other samples

  • Update the /usr/local/driveworks/samples/CMakeLists.txt to include your sample.

  • Create a build directory(ex. ~/build)

  • Follow the steps to build sample on host from DW documentation.

I would expect this to work out of the box. let me know if any issue still exists.

Could NOT find Vulkan (missing: VULKAN_LIBRARY VULKAN_INCLUDE_DIR)
This is what i get when i do cmake.
I only added my project name in cmakelists.txt and copied the folder in src/ . I didnot remove any commands in the cmakelists.txt. Below is the output log.
So the cmake compiled all the samples in the src folder, i have added a copy of the logs in attachment.log.log (14.5 KB)

This is probably because my host laptop doesnt have an nvidia GPU. So then i tried to follow the host compilation steps in the DRIVE-LEARN-host compilation link online, and removed the mentioned lines from the CMakelists.txt and added
set(PROJECTS test_code)
foreach(PROJECT {PROJECTS}) add_subdirectory(src/{PROJECT})
endforeach()

but now i am getting the below given error:

do make -j8
[ 0%] Built target update_cuda_deps
[ 9%] Built target glew-src
[ 18%] Built target lodepng-src
[ 90%] Built target glfw
[ 95%] Linking CXX executable test_code
/usr/bin/ld: cannot find -ldw_samples_framework
collect2: error: ld returned 1 exit status
src/test_code/CMakeFiles/test_code.dir/build.make:107: recipe for target ‘src/test_code/test_code’ failed
make[2]: *** [src/test_code/test_code] Error 1
CMakeFiles/Makefile2:323: recipe for target ‘src/test_code/CMakeFiles/test_code.dir/all’ failed
make[1]: *** [src/test_code/CMakeFiles/test_code.dir/all] Error 2
Makefile:127: recipe for target ‘all’ failed
make: *** [all] Error 2

Dear sanjay.varghese,
Note that you need minimum PASCAL based GPU for testing DW on host.

Okay, Mr.SivaRamaKrishna
I will get back to you after building the samples on a host with an nvidia GPU. and try out the steps again that you have given in the previous reply. Thanks a lot for sticking onto this issue for so long.