Ask Your Question

Revision history [back]

CMake file for CUDA files

I am new to opencv and CMake. I have a .cpp file which pre processes a given image into a a pair of uchar or uint8 arrays on both the host and the device. The first array contains the original image value intensities(both on the host and device). The second array contains a simple inversion (255-pixel value) performed on the device then copied on to the device later.

I wrote my CMakefile to find the cuda executable and link against the main cpp file. But I get an error in which the "main" function is not found. The error is like relocation 0 has invalid symbol index 11

 cmake_minimum_required(VERSION 2.8)
 project( preProcess )
 find_package( OpenCV REQUIRED )
 find_package(CUDA REQUIRED)
 include(FindCUDA)

 include_directories(/usr/local/cuda/include)
 set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -gencode arch=compute_30,code=sm_30)

 file( GLOB  cu  *.cu)
 add_executable( preProcess preProc.cpp )
 CUDA_ADD_EXECUTABLE(test ${preProcess} ${cu})
 target_link_libraries(preProcess /usr/local/cuda/lib64/libcudart.so  ${OpenCV_LIBS} )

When I check my Makefile there is no nvcc command. If you could guide me how to create a CMakeLists.txt file for a project with both cpp files and cu files and link them together or elaborate what I'm doing wrong in my CMakeLists file, it'll be great.

(I'm using Ubuntu 14.04 with CUDA 7 and opencv 2.4.11)