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 CUDALink.cu
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 ) {
…
cudaThreadSynchronize();
dim3 grid(ceil(dataLength/ (float) blocksize));
gpuVectorAddConst<<<grid,blocksize>>>(d_dataVector, addme, dataLength);
cudaThreadSynchronize();
…
}