Linking C and C++ files

Hi all,

I'm actually working with CUDA to link .c and .cu files with nvcc, but since nvcc just treats .c files like C code and .cu files like C++ code I thought this question would be OK for this board. So everything compiles but when it goes to link I get "undefined reference" for functions in .cu files accessed by main.c. Suppose I have main.c and file.cu:

main.c:
1
2
3
4
5
6
#include "prototypes.h"
#include <cuda_runtime.h>
int main(int argc, char *argv[])
{
fileOperation();
}

file.cu:
1
2
3
4
5
6
#include <cuda_runtime.h>
#include "protoypes.h"

extern "C"
void fileOperation(){
}

prototpes.h:
1
2
3
4
5
6
#include <cuda_runtime.h>
#ifdef __cplusplus
extern "C"
#endif

void fileOperation();


As you can see I've tried to use 'extern "C"' to get the compiler to behave but the same errors persist. Is there anything else I could be missing? Thanks!
Topic archived. No new replies allowed.