How to compile and run multiple source C++ code files in

Compiling and running multiple source C++ code files in

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.

1 Like

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 creates an error.
Posting a link to your Repl would help the community troubleshoot with you. :slight_smile:

You can use .hpp files to do maybe what you need.
See: HPP – The C++ Header File

i am facing the same issue…
did you find any solution?

1 Like

Unfortunately I still can’t
do anything about it.

Could I have the Repl link? If you do not want to share it simply private message me on here by clicking my username.

Thanks for trying to help out but the issue is not with any specific repl so i don’t know what to share exactly.

Did you try H++ files?

please share the link if you managed to figure it out

Remove or rename the main function from one file