It is unclear what problem you are experiencing. What specifically doesn’t work, what errors are you seeing? For a worked example of separate compilation, take a look at this thread and in particular posts #9 and #10:
i forgoted show the problem, it’s with DEMono_CUDA.c:
madman@madman-G41M-Combo:~/Escritorio/Cuda/DE$ nvcc -arch=sm_21 -dc DEMono_CUDA.c
In file included from /usr/include/curand_kernel.h:67:0,
from DEMono_CUDA.h:14,
from DEMono_CUDA.c:2:
/usr/include/curand_philox4x32_x.h:109:84: error: expected ‘;’, ‘,’ or ‘)’ before ‘=’ token
QUALIFIERS void Philox_State_Incr_carefully(curandStatePhilox4_32_10_t* s, uint64 n=1)
^
/usr/include/curand_philox4x32_x.h:130:87: error: expected ‘;’, ‘,’ or ‘)’ before ‘=’ token
QUALIFIERS void Philox_State_Incr_carefully_hi(curandStatePhilox4_32_10_t* s, uint64 n=1)
^
/usr/include/curand_philox4x32_x.h: In function ‘Philox_State_Incr’:
/usr/include/curand_philox4x32_x.h:166:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int i=0; i<4; i++)
^
/usr/include/curand_philox4x32_x.h:166:2: note: use option -std=c99 or -std=gnu99 to compile your code
/usr/include/curand_philox4x32_x.h: In function ‘Philox_State_Incr_hi’:
/usr/include/curand_philox4x32_x.h:180:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int i=0; i<4; i++)
^
/usr/include/curand_philox4x32_x.h: At top level:
/usr/include/curand_philox4x32_x.h:186:17: error: conflicting types for ‘Philox_State_Incr’
QUALIFIERS void Philox_State_Incr(curandStatePhilox4_32_10_t* s)
^
/usr/include/curand_philox4x32_x.h:152:17: note: previous definition of ‘Philox_State_Incr’ was here
QUALIFIERS void Philox_State_Incr(curandStatePhilox4_32_10_t* s, uint64 n)
^
/usr/include/curand_philox4x32_x.h: In function ‘Philox_State_Incr’:
/usr/include/curand_philox4x32_x.h:196:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int i=0; i<4; i++)
...
thanks njuffa, i’m reading the thread, if i find the solution i’ll show it.
These compiler error messages would indicate ordinary syntax errors reported by the host compiler. That would appear to be gcc in this case. These have nothing to do with separate compilation. It would appear that you are compiling CUDA supplied header files with a C instead of a C++ compiler.