CUDA and mma--unresolved external symbol

I know there is already some posts for "unresolved external symbol ". I add extern “C”, some functions such as [void cuda_ml_put_vector( void )] no error message coming up any more, but still have one error message for the fuction [ int cuda_ml_add_const_to_vec( void );]which call global function though.

No clue what is wrong in my setup. Any suggestion is appreciated.

(CUDA_BIN_PATH)\nvcc.exe" -ccbin "(VCInstallDir)bin” -c -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/RTC1,/MTd -I"(CUDA_INC_PATH)" -I./ -I../../common/inc -l"C:\CUDA\lib\cudart" -l"C:\CUDA\lib\cutil32" -o (ConfigurationName)\CUDALink.obj

error message=============
1>CUDALinktm.obj : error LNK2019: unresolved external symbol _cuda_ml_add_const_to_vector referenced in function __tr3
1>…/…/bin/win32/Debug/MmaProject.exe : fatal error LNK1120: 1 unresolved externals

#include <stdio.h>
#include <stdlib.h>
#include “mathlink.h”
#include <cuda.h>
#include <cuda_runtime_api.h>

extern “C” void gpuVectorAddConst(float *vec, float addme , int N);
extern “C” void cuda_ml_put_vector( void );
extern “C” int cuda_ml_add_const_to_vec( void );

global void gpuVectorAddConst(float *vec, float addme , int N) {
int idx = blockDim.x * blockIdx.x + threadIdx.x;
if(idx <N) vec[idx] = vec[idx] + addme;

int cuda_ml_add_const_to_vector( void ) {

dim3 grid(ceil(dataLength/ (float) blocksize));
gpuVectorAddConst<<<grid,blocksize>>>(d_dataVector, addme, dataLength);


How about your order about define the function?

This is my order:

global void gpuVectorAddConst(float *vec, float addme , int N)

void cuda_ml_put_vector( void )

void cuda_ml_get_vector( void )

int cuda_ml_add_const_to_vector( void )

Acturally this file passed compile in Linux system, but not my VS2005…

Another story is when I copy one project which works in PC 1 to PC 2, I got the similar error such as “unresolved external symbol”. The only different is at PC1, the NVIDIA Corporation is at C:/NVIDIA Corporation; at PC2, the NVIDIA Corporation is at C:/Program Files/NVIDIA Corporation.

So I suspect something in my VS2005 not configure correctly, but not sure since I am new to VC2005 and CUDA…

Thank you again for any input…

To set the compiler environment of VS2005 by this step : VS->projects->properties