Hi, I’m trying to compile a project I’m working on, it has both .cu and .c files.
When I was using only .cu files, there was no problem, but when I’ve started adding .c files, I simply cannot compile.
Here’s the output of nsight compile line:
**** Build of configuration Debug for project cuSimpleDCT ****
make all
Building file: ../src/ca.cu
Invoking: NVCC Compiler
nvcc -G -g -O0 -gencode arch=compute_20,code=sm_20 -odir "src" -M -o "src/ca.d" "../src/ca.cu"
nvcc --compile -G -O0 -g -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 -x cu -o "src/ca.o" "../src/ca.cu"
Finished building: ../src/ca.cu
Building file: ../src/ga.c
Invoking: NVCC Compiler
nvcc -G -g -O0 -gencode arch=compute_20,code=sm_20 -odir "src" -M -o "src/ga.d" "../src/ga.c"
nvcc -G -g -O0 --compile -x c -o "src/ga.o" "../src/ga.c"
In file included from ../src/ga.h:20,
from ../src/ga.c:17:
../src/ca.h:59: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
../src/ca.h:68: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
../src/ca.h:75: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
../src/ca.h:83: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
make: *** [src/ga.o] Error 1
**** Build Finished ****
NVCC must have been lacking something. I think it needs all the CUDA includes to even compile the source given, but this I am not sure. NVCC manual can be helpful in such matter :)
So, I think I’ve got it sorta working out, I had some static functions giving me trouble.
However, now I can only compile .cu files, not .c, is this supposed to be like this?
Can you check …/src/ca.h:59? It looks like you have CUDA C-specific construct there (e.g. “device” specifier) or something C+±specific.
Note that Nsight specifically sets code language to C in your case (see “-x c”). It may happen that GCC invoked from the command line without such switch autodetects your code as C++ and hence is able to compile it.