Ask coding questions

← Back to all posts
How to get rid of this error?
raza10 (0)

clang++-7 -pthread -std=c++17 -o main main.cpp session3.cpp
/tmp/session3-584966.o: In function main': session3.cpp:(.text+0x0): multiple definition ofmain'
/tmp/main-806584.o:main.cpp:(.text+0x0): first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
compiler exit status 1

Comments
hotnewtop
Coder100 (17137)

Make sure you don't have another main.

Your main.cpp should look like this:

// empty

and your session3.cpp should remain untouched.

Wumi4 (486)

Ok, where's the Repl? And also, I know what your problem is. Just run it without session3.cpp, because simply C++ doesn't let you define more than 1 main function when you compile 1 or multiple files.