I have an existing cmake project in C and for the sake of adding some GPU module in my project, I only changed the following lines in my CMakeList as follows:
Original:
project(test_zip1_gpu)
add_executable(test_zip1_gpu main<b>.c</b> abc.c xyz.c ....)
This builds the project.
Modified version:
project(test_zip1_gpu LANGUAGES C CUDA)
add_executable(test_zip1_gpu main<b>.cu</b> abc.c xyz.c....)
This prompt linking error
main.cu: undefined reference to functions.
The whole process is as follows:
cmake CMakelists.txt
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nomi/cuda-workspace/test_zip1_gpu
make
I haven’t modified anything in my project files and now the functions defined in [abc.c, xyz.c …] aren’t linking with the final executable, though i have just change the extension of main.c to main.cu.