Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22117

My compiler is giving me an error about multiple definitions of functions

$
0
0

I am new to C and am trying to create a makefile. I have to compile the following files: A2.c (functions) a2_q1.c (consists of the main function) and a2_q1.c (consists of another main function). This is what I have:

makefile:

 CC = GCC
 CCFLAGS = -Wall

main: A2.o a2_q2.o a2_q1.o
       $(CC) $(CCFLAGS) -o main a2_q2.o a2_q1.o A2.o
a2_q2.o: a2_q2.c
       $(CC) $(CCFLAGS) -c a2_q2.c
a2_q1.o: a2_q1.c
       $(CC) $(CCFLAGS) -c a2_q1.c
A2.o: A2.c
       $(CC) $(CCFLAGS) -c A2
clean:
    rm -f main A2.o a2_q2.o a2_q1.o

Every time I run this I get the following error: Image of output result

Please advice.


Viewing all articles
Browse latest Browse all 22117

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>