Error of function is undefined, while the function is defined

I am compiling a library using a makefile and the structure of the code is as below. I have a cuda header file “cuda_functions.cuh” and its cuda file “cuda_functions.cu” and a main file “main.cu”. When I am trying to compile the code while including “cuda_functions.cuh” I get no error, also the object file (i.e. cuda_functions.o) is created, but when I am trying to call a function of it i.e. call_from_main(), I get this error:
error: identifier “call_from_main” is undefined

any advice would be highly appreciated.

cuda_functions.cuh

const int n=4;
typedef float data;
#define MAX_DATA INT_MAX
#define MIN_DATA INT_MIN
__device__ int array[n];			
__device__ int device_fun();
inline __device__ inline_fun(void);
__global__ void global_fun(float*, int);

void call_from_main(float*, int);

cuda_functions.cu

#include<cuda_functions.cuh>
__device__ 
int device_fun()
{
    ....
}
inline __device__ 
inline_fun(void)
{
    ....
}
__global__
void global_fun(float*, int)
{
    device_fun();
    ....
    inline_fun();
    ....
}
void call_from_main(float* a, int b)
{

	    global_fun<<<1,1>>>(a, b);
}

main.cu

#include<cuda_functions.cuh>

int main(int argc, char* args[])
{
    float* a=(float*) malloc(sizeof(float)*5);
    call_from_main(a,5);
}

makefile

CUDAMain: main.cu
    nvcc -rdc=true --generate-code arch=compute_35,code=compute_35 main.cu \-std=c++11 -o result -I.

Hi @s.yousefi.radi
Thank you for your report. Is this problem related to CUDA GDB (since it’s reported in the CUDA GDB forum branch)? The post never mentioned CUDA GDB.

If it’s not CUDA GDB related, please consider different forum branch, e.g.: CUDA - NVIDIA Developer Forums or CUDA Programming and Performance - NVIDIA Developer Forums

If it’s related to CUDA GDB, please provide more details.

just edited the tags

It would be better to move it to a corresponding sub-forum. This one is dedicated to CUDA GDB, so it’s unlikely someone from nvcc support team would look at this.

I think now it is fixed?

Yes, it’s in the correct branch now. Thank you!

your makefile isn’t compiling cuda_functions.cu

try something like this:

CUDAMain: main.cu cuda_functions.cu
    nvcc -rdc=true --generate-code arch=compute_35,code=compute_35 cuda_functions.cu main.cu \-std=c++11 -o result -I.