My environment:
driver : 197.13
toolkit & sdk : 3.0
os: win7 ultimate x64
ide: vs2008 sp1
My CUDA project in VS use cuda custom build rule v3.0.14 from SDK. Single file compile OK using build rule. But when linking, some strange errors occur:
I have add “/GS-” option.
Step : Right click project → Project properties → … → CUDA Build Rule v3.0.14 → Hybrid CUDA/C++ Options → Extra C++ Options
Otherwise, i will have “error LNK2001: unresolved external symbol __GSHandlerCheck”
I have installed x64 compiler add-ons of Visual Studio. And I can run the samples in SDK correctly.
Anyone know what’s going on? Thank you!
main.cu
#include <stdio.h>
#include <cuda_runtime.h>
#include <cutil.h>
#if __DEVICE_EMULATION__
bool InitCUDA(void){return true;}
#else
bool InitCUDA(void)
{
int count = 0;
int i = 0;
cudaGetDeviceCount(&count);
if(count == 0) {
fprintf(stderr, "There is no device.\n");
return false;
}
for(i = 0; i < count; i++) {
cudaDeviceProp prop;
if(cudaGetDeviceProperties(&prop, i) == cudaSuccess) {
if(prop.major >= 1) {
break;
}
}
}
if(i == count) {
fprintf(stderr, "There is no device supporting CUDA.\n");
return false;
}
cudaSetDevice(i);
printf("CUDA initialized.\n");
return true;
}
#endif
int main(int argc, char** argv)
{
printf("Hello world\n");
if (!InitCUDA())
{
return 0;
}
return 0;
}