Reputation: 245
Ok, here I have a problem with my makefile . I have the files MatMulCpu.cu, MatMulGPU.cu, MatMulGPU_ms.cu I want to compile them and compile the file MatMul.cu, which needs those three files . Here is my makefile...
CC=nvcc
EXEC=MatMul
all: $(EXEC)
MatMul: MatMulGPU_ms.o MatMulCPU.o MatMulGPU.o
$(CC) -o MatMul MatMulCPU.o MatMulGPU.o MatMulGPU_ms.o
MatMulCPU.o: MatMulCPU.cu
$(CC) -o MatMulCPU.o MatMulCPU.cu
MatMulCPU.o: MatMulGPU.cu
$(CC) -o MatMulGPU.o MatMulGPU.cu
MatMulCPU.o: MatMulGPU_ms.cu
$(CC) -o MatMulGPU_ms.o MatMulGPU_ms.cu
clean:
rm -rf *.o
mrproper: clean
rm -rf MatMul
And I have those warnings and errors :
makefile:12: warning: overriding commands for target `MatMulCPU.o'
makefile:9: warning: ignoring old commands for target `MatMulCPU.o'
makefile:15: warning: overriding commands for target `MatMulCPU.o'
makefile:12: warning: ignoring old commands for target `MatMulCPU.o'
make: *** No rule to make target `MatMulGPU.cu', needed by `MatMulCPU.o'. Stop.
Don't know what to solve it . Searched several makefiles on the internet, but it couldn't help me :/
EDIT : Ok thanks now I modified the makefile, it seems to be ok
CC=nvcc
EXEC=MatMul
all: $(EXEC)
MatMul: MatMulGPU_ms.o MatMulCPU.o MatMulGPU2.o
$(CC) -o MatMul MatMulCPU.o MatMulGPU2.o MatMulGPU_ms.o
MatMulCPU.o: MatMulCPU.cu
$(CC) -o MatMulCPU.o MatMulCPU.cu
MatMulGPU2.o: MatMulGPU2.cu
$(CC) -o MatMulGPU2.o MatMulGPU2.cu
MatMulGPU_ms.o: MatMulGPU_ms.cu
$(CC) -o MatMulGPU_ms.o MatMulGPU_ms.cu
clean:
rm -rf *.o
mrproper: clean
rm -rf MatMul
But now I have others errors...
MatMulGPU.o: In function `_start':
(.text+0x0): multiple definition of `_start'
[...manythings_here_that_shows_all_the_multiple_definitions...]
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o:/build/buildd/eglibc-2.19/csu/../sysdeps/x86_64/start.S:118: first defined here
I have the same for some stuff, like _fini, IO_stdin_used, _data_start, _dso_handle ... I don't know what it is !
Is this due to the make file or to the code ?
It seems to say that also other stuff, like main functions or Matrix definitions that are said to be more than one time defined...but the definitions aren't in the same file ! For example, I have a Matrix definition in MatMulCPU.cu and MatMulGPU2.cu, so why is it a problem ....? :/
Upvotes: 0
Views: 1528
Reputation: 151799
You are specifying the same target (MatMulCPU.o
) multiple times. There is no need to do this. But you should have a target for each object (.o) that will be built.
Try this:
CC=nvcc
EXEC=MatMul
all: $(EXEC)
MatMul: MatMulGPU_ms.o MatMulCPU.o MatMulGPU.o
$(CC) -o MatMul MatMulCPU.o MatMulGPU.o MatMulGPU_ms.o
MatMulCPU.o: MatMulCPU.cu
$(CC) -c -o MatMulCPU.o MatMulCPU.cu
MatMulGPU.o: MatMulGPU.cu
$(CC) -c -o MatMulGPU.o MatMulGPU.cu
MatMulGPU_ms.o: MatMulGPU_ms.cu
$(CC) -c -o MatMulGPU_ms.o MatMulGPU_ms.cu
clean:
rm -rf *.o
mrproper: clean
rm -rf MatMul
Upvotes: 2