Hello everyone, I’m a beginner in CUDA and I’m trying to run my first example on my PC.
I have tried the DeviceQuery project and it show the result successfully, but when I start to make my own problems occurs.
this is the error message :
test.obj : error LNK2019: unresolved external symbol _runMyFirstKernel referenced in function _main
look at my code and tell me what’s the problem ??
test.cpp
#include <stdio.h>
#include <stdlib.h>
#include <shrUtils.h>
#include "cutil_inline.h"
#include <cuda.h>
#include <kernel.cuh>
int main()
{
//all variables should declared before the code
int nBytes;
int nElements = 8;
int *d_a = 0;
int x =0;
int i =0,ii=0;
cudaMalloc((void**)&d_a, nBytes);
cudaMemset((void**)&d_a,0, nBytes);
runMyFirstKernel(d_a); //the problem here
cudaFree((void**)&d_a);
system("pause");
}
kernel.cu
__global__ void myFirstKernel(int *d_a)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
d_a[idx] = idx*10;
}
void runMyFirstKernel(int *d_a)
{
myFirstKernel<<<1,8>>>(d_a);
}
kernel.cuh
extern "C"
{
void runMyFirstKernel(int *d_a);
}