I have a project consisting of two files, main.c and logoff.c. When I try to compile them I get this error:
gcc -c -g -Wall main.c
gcc -c -g -Wall logoff.c
gcc -o main -g -Wall main.o logoff.o
ld: duplicate symbol _logoff in logoff.o and main.o
I have a function named logoff in logoff.c, but I have searched main.c for the text "logoff" and have found nothing (the function is not even called yet!).
If I change the name of the function to log_off it works. There is a second function in the file which then causes the same error unless its name is changed as well.
Is there any reason why this might occur? I have this problem on two different systems. One thing that might be relevant is that I used the same logoff.c file in another project but it is not connected to this one.