Compiling cpp files in CUDA

I have several cpp files and I want to port some parts of the code to CUDA. So, I have decided to start for allocating device memory and I am doing in in main.cpp
First, if we do not write anything from CUDA, it compiles fine:

nvcc -L/usr/local/cuda/lib -lcutil -lcudpp -lcuda -lcudart -c -o FSPB_main.o FSPB_main.cpp
nvcc -L/usr/local/cuda/lib -lcutil -lcudpp -lcuda -lcudart -c -o a.o a.cpp
nvcc -L/usr/local/cuda/lib -lcutil -lcudpp -lcuda -lcudart -c -o b.o b.cpp
etc

However, just writing in the main body :

float d_a;
cudaMalloc( (void
*)&d_a, 5*sizeof(float) );

it returns the next error:
FSPB_main.cpp: In function ‘int main(int, char**)’:
FSPB_main.cpp:167:45: error: ‘cudaMalloc’ was not declared in this scope
make: *** [FSPB_main.o] Error 1

I read that cudaMalloc was c++ supported. So, what do i need to do in order to compile it fine? Shall I create a .cu file just for allocating device memory?

I have several cpp files and I want to port some parts of the code to CUDA. So, I have decided to start for allocating device memory and I am doing in in main.cpp
First, if we do not write anything from CUDA, it compiles fine:

nvcc -L/usr/local/cuda/lib -lcutil -lcudpp -lcuda -lcudart -c -o FSPB_main.o FSPB_main.cpp
nvcc -L/usr/local/cuda/lib -lcutil -lcudpp -lcuda -lcudart -c -o a.o a.cpp
nvcc -L/usr/local/cuda/lib -lcutil -lcudpp -lcuda -lcudart -c -o b.o b.cpp
etc

However, just writing in the main body :

float d_a;
cudaMalloc( (void
*)&d_a, 5*sizeof(float) );

it returns the next error:
FSPB_main.cpp: In function ‘int main(int, char**)’:
FSPB_main.cpp:167:45: error: ‘cudaMalloc’ was not declared in this scope
make: *** [FSPB_main.o] Error 1

I read that cudaMalloc was c++ supported. So, what do i need to do in order to compile it fine? Shall I create a .cu file just for allocating device memory?