Hello
I’m implementing a cuda program. But it has two link errors, “error LNK2019: unresolved external symbol” and “fatal error LNK1120: 1 unresolved externals”.
I have several header files(.cuh) and source files(.cu) and my source is like below:
"definition.cuh"
#ifndef _DEF_CUH_
#define _DEF_CUH_
typedef struct vector_1 {
float v[3];
} vector_1;
typedef struct matrix_1 {
float m[3][3];
} matrix_1;
typedef struct transMat {
matrix_1 mat;
vector_1 vec;
} transMat;
#endif
"handle.cuh"
#ifndef _HANDLE_CUH_
#define _HANDLE_CUH_
#include "definition.h"
typedef struct handle{
transMat tm1;
transMat tm2;
transMat tm3;
transMat tm4;
transMat tm5;
} handle;
__host__ __device__ handle setHandle(transMat mat);
#endif
"handle.cu"
#include "handle.cuh"
#include "definition.cuh"
#include "funcDec.cuh"
__host__ __device__ handle setHandle(transMat mat) {
handle res;
res.tm1= setTransMat(mat);
res.tm2= setTransMat();
res.tm3= setTransMat();
// These functions are declared in "funcDec.cuh" file and defined in "transMat.cu" file.
return res;
}
"main.cu"
#include "definition.cuh"
#include "funcDec.cuh"
#include "handle.cuh"
int main() {
....
handle* handles0;
handles0 = (handle*) malloc(sizeof(handle)*100);
transMat mat;
....
for(i=0; i<100; i++) {
handles0[i] = setHandle(mat);
}
....
if I don’t include “handle.cu” and just include “handle.cuh”, then link errors occur at setHandle function.
I don’t know how can I solve this problem without including “handle.cu” file.
Please give me any advice.
Thank you.