How to compile and run multiple source C++ code files in repl.it?

Compiling and running multiple source C++ code files in repl.it

Hey @AdityaRawat28, welcome to the forums!

You can only run 1 file at once, to change the file you’re running, you should click on the 3 buttons, select hidden files, scroll down and click on the .replit file and change the string in the entrypoint line!

To add:

I don’t know how C++ works but you may be able to import stuff into one file.

Thanks for the advice i tried it but now none of the files will compile and this is what its showing and idea how to fix it

/nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld: /tmp/patterns2-b42a79.o: in function `main':
/home/runner/Patterns/./patterns2.cpp:4: multiple definition of `main'; /tmp/main-cacca6.o:/home/runner/Patterns/./main.cpp:4: 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

Thanks for your help but I’m a newbie so do you mind explaining how to do this.

I would but I do not C++ so I am unable to

No problem, thanks anyways

It seems based on the error that you declare themain function in multiple of those files, this creating an error.
Posting a link to your reply would help the community troubleshoot with you. :slight_smile:

Facing similer issue