Hello everyone!
System information:
Windows Vista Home, SP2
Toolkit 2.2
SDK 2.2.1
Driver 186.03
Visual C++ 2008 Express Edition
I am able to compile and run the example Files of CUDA. I have also completed all steps of the Getting Started Document and varified that the installition is correct. Now I am trying to make my own example. Therefore I add a new directory in examples named testFiles where I have the file test1.cu with the following simple code:
#include<stdio.h>
#include<cuda.h>
// Kernel definition
global void VecAdd(float* A, float* B, float* C)
{
int i = threadIdx.x;
C[i] = A[i] + B[i];
}
int main()
{
int N = 5;
int i;
float A[5], B[5], C[5];
for(i = 0; i < 5; i++) {
A[i] = i + 0.25;
B[i] = i + 0.5;
C[i] = 0;
}
// Kernel invocation
VecAdd<<<1, N>>>(A, B, C);
return 0;
}
By now clicking on Start Debugging following error occurs:
What I am doing wrong?
Greets Alex
OK, the problem discribed above has been solved … but there is a new one, I have expanded the program a little bit
#include<stdio.h>
#include<stdlib.h>
#include<C:\CUDA\include\cuda.h>
define N 5
// Kernel definition
extern “C” global void VecAdd(float* A, float* B, float* C)
{
int i = threadIdx.x;
if(i < N)
C[i] = A[i] + B[i];
}
extern “C” int main()
{
int i;
size_t size = N * sizeof(float);
//Allocate Memory for Device
float *d_A;
cudaMalloc((void**) &d_A, size);
float *d_B;
cudaMalloc((void**) &d_B, size);
float *d_C;
cudaMalloc((void**) &d_C, size);
//Allocate Memory for Host
float *h_A;
h_A = (float *) malloc(size);
float *h_B;
h_B = (float *) malloc(size);
float *h_C;
h_C = (float *) malloc(size);
for(i = 0; i < 5; i++) {
h_A[i] = i + 0.25;
h_B[i] = i + 0.5;
}
cudaMemcpy(d_A,h_B,size,cudaMemcpyHostToDevice);
cudaMemcpy(d_B,h_B,size,cudaMemcpyHostToDevice);
// Kernel invocation
VecAdd<<<1, N>>>(d_A, d_B, d_C);
cudaMemcpy(h_C,d_C,size,cudaMemcpyDeviceToHost);
cudaFree(d_A);
cudaFree(d_B);
cudaFree(d_C);
free(h_A);
free(h_B);
free(h_C);
return 0;
}
Error:
I am using the German version - the Error is “error LNK2019: unresolved external symbol”
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “___cudaUnregisterFatBinary@4” in Funktion “___cudaUnregisterBinaryUtil”.
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “_cudaLaunch@4” in Funktion ““enum cudaError __cdecl cudaLaunch(char *)” (??$cudaLaunch@D@@YA ?AW4cudaError@@PAD @Z)”.
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “_cudaSetupArgument@12” in Funktion “__device_stub__Z6VecAddPfS_S ”.
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “___cudaRegisterFunction@40” in Funktion "___sti____cudaRegisterAll_40_tmpxft_00001508_00000000_6
_test1_cpp1_ii_VecAdd".
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “___cudaRegisterFatBinary@4” in Funktion "___sti____cudaRegisterAll_40_tmpxft_00001508_00000000_6
_test1_cpp1_ii_VecAdd".
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “_cudaFree@4” in Funktion “_main”.
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “_cudaConfigureCall@32” in Funktion “_main”.
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “_cudaMemcpy@16” in Funktion “_main”.
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “_cudaMalloc@8” in Funktion “_main”.
1>C:\ProgramData\NVIDIA Corporation\NVIDIA CUDA SDK\projects\testFiles\Debug\testFiles.exe : fatal error LNK1120: 9 nicht aufgelöste externe Verweise.
I read some topics with the same error and added the extern “C” thing, but it won’t help.
Does noone have any advice for me? :( If i posted in the wrong forum, please let me know
Regards
OK, the problem discribed above has been solved … but there is a new one, I have expanded the program a little bit
Error:
I am using the German version - the Error is “error LNK2019: unresolved external symbol”
I read some topics with the same error and added the extern “C” thing, but it won’t help.
External Media
I have exactly the same problem. I added in Linker Additional Dependencies msvcrt.lib.
that helped on some errors. but 10 errors are also with my compilation script on.Same then on yours.
Regards
teraflop
:rolleyes:
the problem is at another point.
the cuda/bin
there are bin2c.exe fatbin.exe filehash.exe
they all refer to dlls
a wer.dll bcrypt.dll and ncrypt.dll
if this 3 dlls are x86 they will not run on an x64 CPU environement
so for example fatbin cannot make the link then correctly
regards
teraflop