In learning about make-files I have stumbled upon this error, and my teachers can't seem to point me the right direction. Having searched and read several related questions I still can't seem to see the answer. The thing that surprises me is that I don't get errors in NetBeans.
Makefile:
connect4: connect4.o basicBoardFunctions.o evaluationOfBoard.o hashCoding.o iaMinMaxing.o manageInput.o manageInputGeneral.o connect4.o
gcc -o connect4 connect4.o basicBoardFunctions.o evaluationOfBoard.o hashCoding.o iaMinMaxing.o manageInput.o manageInputGeneral.o connect4.o
connect4.o: connect4.c
gcc -c connect4.c
basicBoardFunctions.o: basicBoardFunctions.c
gcc -c basicBoardFunctions.c
evaluationOfBoard.o: evaluationOfBoard.c
gcc -c evaluationOfBoard.c
hashCoding.o: hashCoding.c
gcc -c hashCoding.c
iaMinMaxing.o: iaMinMaxing.c
gcc -c iaMinMaxing.c
manageInput.o: manageInput.c
gcc -c manageInput.c
manageInputGeneral.o: manageInputGeneral.c
gcc -c manageInputGeneral.c
clean:
rm connect4.o basicBoardFunctions.o evaluationOfBoard.o hashCoding.o iaMinMaxing.o manageInput.o manageInputGeneral.o tests.o connect4.o
The error I got:
gcc -o connect4 connect4.o basicBoardFunctions.o evaluationOfBoard.o hashCoding.o iaMinMaxing.o manageInput.o manageInputGeneral.o connect4.o
connect4.o: In function `main':
connect4.c:(.text+0x0): multiple definition of `main'
connect4.o:connect4.c:(.text+0x0): first defined here
connect4.o: In function `getInputSource':
connect4.c:(.text+0xea): multiple definition of `getInputSource'
connect4.o:connect4.c:(.text+0xea): first defined here
connect4.o: In function `startGame':
connect4.c:(.text+0x1a9): multiple definition of `startGame'
connect4.o:connect4.c:(.text+0x1a9): first defined here
connect4.o: In function `anounceWinner':
connect4.c:(.text+0x2ac): multiple definition of `anounceWinner'
connect4.o:connect4.c:(.text+0x2ac): first defined here
collect2: ld returned 1 exit status
All this functions are defined only once in the main file "connect4.c" which is not included anywhere. I don't know what to try but I thought it might be obvious to the trained person. I feel like I'm going to get much criticism but I don't see the other situations apply to me.
Problem is in double linking the same object file, connect4.o:
connect4: connect4.o ... connect4.o
gcc -o connect4 connect4.o ... connect4.o
Remove one of this files and all be fine:
connect4: connect4.o ...
gcc -o connect4 connect4.o ...