Linking error please help me !!

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 ??


#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




__global__ void myFirstKernel(int *d_a)


    int idx = blockIdx.x * blockDim.x + threadIdx.x;

    d_a[idx] = idx*10;


void runMyFirstKernel(int *d_a)





extern "C"


	void runMyFirstKernel(int *d_a);



Need to read cuda documentation first, not just examples from sdk, cuda programming guide.

thank you for your comment .

anybody else can help???

I’m using Visual Studio 2008 and windows-7 64-bit

try to declare calling conventions of all functions, like __cdecl

Have you tried getting rid of
extern “C”

Either decare [font=“Courier New”]runMyFirstKernel()[/font] as [font=“Courier New”]extern “C”[/font], or compile using the [font=“Courier New”]–host-compilation C[/font] flag, or remove the [font=“Courier New”]extern “C”[/font] declaration on the header file.