I am using the Makefile which is provided for each example in the SDK, which references the default common.mk and I’m getting this error while trying to compile my own program.
/usr/lib/gcc/x86_64-linux-gnu/4.3.3/…/…/…/…/lib/crt1.o: In function _start': /build/buildd/glibc-2.9/csu/../sysdeps/x86_64/elf/start.S:109: undefined reference to main’
collect2: ld returned 1 exit status
I’ve maintained the structure provided in the example threadMigration, or in any example in the SDK programmes. I’ve browsed this error and from the error reports I’ve read it might be a 64-bit compiling problem. I’ve sucessfully installed Cuda 2.3 and compiled the examples provided by the SDK. The GCC is 4.3.3 version. I’ve add to the LD_LIBRARY_PATH and the other path its requirements, and as all the other SDK programmes compiled and ran sucessfully I can’t seem to point out the origin of the error. Any help is welcomed.
The linker is telling you it cannot find a main() function amongst the object files you have provided for it to link,which either means
(1) You don’t have a main(), in which case you need to write one, or
(2) You have a main, but you haven’t provided the object file containing it to the linker, in which case you need to modify your makefile
(2) is probably more likely, but only you know that for sure…
OK this is embarrassing… It was one of those typical copy paste cases where the copy paste action must follow a sequence, I’ve tried again with new .cu, .cpp and kernel files and it has now finally compiled!
Hello, I encounter the same problem, but I don’t want to have a main method. There is another .c file that calls a method contained in the .cu file. Is there a way to compile a .cu file without a main method ?
You can simply compile it with nvcc --compile, it will skip linking then which allows you to link the cuda code to normal c code later on, though you’ll have to pass some extra options to the linker so it wont forget the cuda libs