Problem when calling a function in an external C file from a cuda file

Hi all,

I have a C code (io.c) which compiles and runs perfectly. I am trying to call a function of the C code (io.c) from a cuda file (

extern "C"{

#include "io.h"


#include "cuda.h"
#include "myMethods.h"

int main(int argc, char** argv){

//... everything no related to the function has been commented
here I call to a function which is declared in io.h and implemented in io.c


I am using the following Makefile to compile and link io.c and

MKL =1



CUDALIBS=-lcublas -lcudart
utilS=  -lpthread  -lm 

CFLAGS= -Wwrite-strings

CUDAFLAGS= --gpu-architecture sm_20

io.o : io.c
	icc $(CFLAGS) -c -O3 io.c -o $(BUILD_DIR)/io.o

#everything is already compiled, this is just a call to the linker
PCA: io.o PCA.o
	icc $(CFLAGS) $(BUILD_DIR)/io.o $(BUILD_DIR)/PCA.o $(CUDA_LIB_DIR) $(utilS) $(CUDALIBS)  -o PCA

And I get segmentation fault (core dumped) when I run the generated executable (./PCA)

Any help?

Thanks in advance