Hello, and thank you very much for developing this CUDA C plugin for eclipse!
First of all let me say that I am completely new with cuda. I’ve been programming cpp for quite a while, but with eclipse, all I did was to write my code and header files, and everything else was done for me. aka, I’ve never been bothered with makefiles etc. (and maybe its time). So, feel free -and please do- correct anything mis-stated below!
I’ve installed the plugin as described in the first post, i’ve added to my project a .cu file with the following simple code i found in a tutorial:
[codebox]
#include “assert.h”
int main(void)
{
float *a_h, *b_h; // host data
float *a_d, *b_d; // device data
int N = 14, nBytes, i ;
nBytes = N*sizeof(float);
a_h = (float *)malloc(nBytes);
b_h = (float *)malloc(nBytes);
cudaMalloc((void **) &a_d, nBytes);
cudaMalloc((void **) &b_d, nBytes);
for (i=0; i<N; i++) a_h[i] = 100.f + i;
cudaMemcpy(a_d, a_h, nBytes, cudaMemcpyHostToDevice);
cudaMemcpy(b_d, a_d, nBytes, cudaMemcpyDeviceToDevice);
cudaMemcpy(b_h, b_d, nBytes, cudaMemcpyDeviceToHost);
for (i=0; i< N; i++) assert( a_h[i] == b_h[i] );
free(a_h); free(b_h); cudaFree(a_d); cudaFree(b_d);
return 0;
}
[/codebox]
giving the built all command, i get the following errors (i give just the highlights in order not to take much space)
[codebox]./cu_memtrans.o: In function `__sti____cudaRegisterAll_43_tmpxft_00001916_00000000_4_m
emtrans_cpp1_ii_main()':
tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0xa24f): undefined reference to `__cudaRegisterFatBinary’
./cu_memtrans.o: In function `__ftexfetch(void const*, float4, int)':
tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0xc1e3): undefined reference to `__cudaTextureFetch’
./cu_memtrans.o: In function `__utexfetch(void const*, float4, int)':
…
undefined reference to `__cudaSynchronizeThreads’
…
undefined reference to `__cudaMutexOperation’
…[/codebox]
and also (after that):
[codebox]tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x10721): undefined reference to `cudaMalloc’
tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x10730): undefined reference to `cudaMalloc’
tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x1077f): undefined reference to `cudaMemcpy’
tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x10797): undefined reference to `cudaMemcpy’
tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x107af): undefined reference to `cudaMemcpy’
tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x1082c): undefined reference to `cudaFree’
tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x10835): undefined reference to `cudaFree’[/codebox]
do note that compiling this same file from console with
[codebox]nvcc bla.cu -o b.out[/codebox]
everything works just file (at least it seams so).
Also, I don’t know if this makes any difference, I’m running eclipse on Ubuntu linux.
Another thing I’d like to ask -even if it is kind of “out of topic”-… I read in a thread that the c part of the code has to be in a c/cpp file, whereas the cuda part of the code has to be in a .cu file. The thing is that I’ve been reading the programming guide, and this isn’t stated anywhere, and also all the sample code files from the SDK are .cpp files! -please do comment on that too if you can-
Thank you very much in advance for any answers.
p.s. sorry - I don’t know why my code-boxes are so huge! :-)