Error with cuPrintf

Hello,

I am using the “HelloWorld” example on “http://code.google.com/p/stanford-cs193g-sp2010/wiki/TutorialHelloWorld”.

On console it works fine, but with the eclipse toolchain from university of bayreuth, I get the following error:

**** Build of configuration Default for project HelloWorld_CUDA ****

make all
Building file: …/src/util/cuPrintf.cu
Invoking: CUDA NVCC Compiler
nvcc -c -I/usr/local/cuda/include -o “src/util/cu_cuPrintf.o” “…/src/util/cuPrintf.cu” &&
echo -n ‘src/util/cu_cuPrintf.d’ src/util/ > ‘src/util/cu_cuPrintf.d’ &&
nvcc -M -I/usr/local/cuda/include “…/src/util/cuPrintf.cu” >> ‘src/util/cu_cuPrintf.d’
…/src/util/cuPrintf.cu(308): warning: function “copyArg(char *, const char *, char *)” was declared but never referenced

…/src/util/cuPrintf.cu(308): warning: function “copyArg(char *, const char *, char *)” was declared but never referenced

…/src/util/cuPrintf.cu: In function ‘int outputPrintfData(char*, char*)’:
…/src/util/cuPrintf.cu:643: warning: format not a string literal and no format arguments
Finished building: …/src/util/cuPrintf.cu

Building file: …/src/hello_world.cu
Invoking: CUDA NVCC Compiler
nvcc -c -I/usr/local/cuda/include -o “src/cu_hello_world.o” “…/src/hello_world.cu” &&
echo -n ‘src/cu_hello_world.d’ src/ > ‘src/cu_hello_world.d’ &&
nvcc -M -I/usr/local/cuda/include “…/src/hello_world.cu” >> ‘src/cu_hello_world.d’
…/src/util/cuPrintf.cu: In function ‘int outputPrintfData(char*, char*)’:
…/src/util/cuPrintf.cu:643: warning: format not a string literal and no format arguments
Finished building: …/src/hello_world.cu

Building target: HelloWorld_CUDA
Invoking: C++ Linker
nvcc -Xlinker -rpath,/usr/local/cuda/lib -o “HelloWorld_CUDA” ./src/util/cu_cuPrintf.o ./src/cu_hello_world.o -lcudart
./src/cu_hello_world.o: In function cuPrintf(char const*)': tmpxft_00000de2_00000000-1_hello_world.cudafe1.cpp:(.text+0x8f): multiple definition of cuPrintf(char const*)’
./src/util/cu_cuPrintf.o:tmpxft_00000d96_00000000-1_cuPrintf.cudafe1.cpp:(.text+0x8f): first defined here
./src/cu_hello_world.o: In function cuPrintfRestrict(int, int)': tmpxft_00000de2_00000000-1_hello_world.cudafe1.cpp:(.text+0xa7): multiple definition of cuPrintfRestrict(int, int)’
./src/util/cu_cuPrintf.o:tmpxft_00000d96_00000000-1_cuPrintf.cudafe1.cpp:(.text+0xa7): first defined here
./src/cu_hello_world.o: In function cudaPrintfInit': tmpxft_00000de2_00000000-1_hello_world.cudafe1.cpp:(.text+0x487): multiple definition of cudaPrintfInit’
./src/util/cu_cuPrintf.o:tmpxft_00000d96_00000000-1_cuPrintf.cudafe1.cpp:(.text+0x487): first defined here
./src/cu_hello_world.o: In function cudaPrintfEnd': tmpxft_00000de2_00000000-1_hello_world.cudafe1.cpp:(.text+0x5d9): multiple definition of cudaPrintfEnd’
./src/util/cu_cuPrintf.o:tmpxft_00000d96_00000000-1_cuPrintf.cudafe1.cpp:(.text+0x5d9): first defined here
./src/cu_hello_world.o: In function cudaPrintfDisplay': tmpxft_00000de2_00000000-1_hello_world.cudafe1.cpp:(.text+0x61a): multiple definition of cudaPrintfDisplay’
./src/util/cu_cuPrintf.o:tmpxft_00000d96_00000000-1_cuPrintf.cudafe1.cpp:(.text+0x61a): first defined here
collect2: ld returned 1 exit status
make: *** [HelloWorld_CUDA] Error 1

I don’t understand this error message. Has anybody an idea, what is wrong?

I’ve got the same error and I have no idea why? Did you solve it?

Please consult the documentation first.

cuPrintf is history.

CUDA now supports regular printf.

cuPrintf is still useful on compute capability 1.x devices, which don’t support printf.

As for the original poster’s problem, I have no idea how to fix it since the build system seems to be a rather complex Makefile.

Sorry, I seem to have forgotten about Compute 1.x devices since I got my new card :)

I have used the eclipse toolchain with success before and the problem here is that cuPrintf.cu is being compiled and linked twice.

The toolchain compiles it the first time because it recognizes it as a .cu file and then it compiles it again because it is included in the main file.

To fix it either rename cuPrintf.cu to cuPrintf.h or simply exclude it from the build.

Yes this worked for me…thanks