Getting multiple main() function error.

Question:
I was trying to run a C code and got this error, “/nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld: /tmp/main_1-776ec8.o: in function main': /home/runner/ANSI-C/./main_1.c:3: multiple definition of main’; /tmp/main-13ff03.o:/home/runner/ANSI-C/./main.c:3: first defined here
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:10: main] Error 1
exit status 2”
Repl link:
https://replit.com/@SadifHasan/ANSI-C?v=1

code snippet
```Preformatted text

Not sure what you are trying to accomplish, but the makefile is pulling in both main_1.c and main.c. They both contain a “main” function and thus conflict when they try to link the two together.
It looks like main.c is a simple “Hello World”.
I renamed main.c to old_main.kep and was able to compile.
I executed the result with ./main without issue. Best of luck

1 Like