Cross Compiling CUDA For ARM - Linker Problems (CARMA)

All, I am using a CARMA board for development and am attempting to compile a test program. I am having trouble with a few linker calls and was hoping I could get some assistance.

My development environment:

  1. arm-linux-gnueabi-gcc-4.5
  2. CMake v. 2.8.10 - using find_package(CUDA 4.2)
  3. Super helpful toolchain file from OpenCV - "arm-gnueabi.toolchain.cmake"

My errors are as follows:

  • arm-linux-gnueabi-ld can’t find lcudart.so. (I tried so many CMake variables to adjust this, and no matter what nothing. I finally solved it by hacking it:
    set(CUDA_LIBRARIES “/direct/path/to/workspace/CarmaDev/cuda/lib/libcudart.so”)

  • My next problem is that all function calls defined in my *.cu scream “undefined reference” yet I see the generated file in the arm-linux-gnueabi call.

Please could anyone offer any assistance? I’ll be glad to post my example cmake file for future arm developers.

Okay, I found another way of compiling and linking but I am still getting an undefined reference. My project layout is as follows:

test_functions.c

  • cuda_functions/rgbtogray.cu
  • cuda_functions/rgbtogray.cuh

test_functions.c includes rgbtogray.cuh. I compile object files with CUDA_COMPILE then add those object files to a

add_executable(test_my_functions test_functions.c ${CUDA_OBJECTS})

However, I still get an undefined reference in my test_functions.c relating to a function I wrote in my rgbtogray.cu

I am not familiar with the CARMA board setup, but your link issue appears to be a generic C / C++ link issue. CUDA compiles all code as C++ code, and this means all function names in the object file are decorated in the C++ manner. C on the other hand expects undecorated function names. As the names are therefore different the linker cannot resolve the references. If you declare those functions in your .cu that comprise the externally visible interface as extern “C” I would expect the link issue to disappear.

Njuffa that was exactly it I just discovered it on StackOverflow. I had to extern “C” my function.