Skip to content
← Back to Community
How to configure run button for C++ repository
Profile icon
Glare

Hi there. I'm new to Repl, and I have been trying to run some C++ files from my repository but unfortunately, I don't know what to put for "Configure run button". How can I run any C++ file from my repo that I am looking at. I have many of them in my repo, so do I have to configure it every time? Thank you.

Answered by DynamicSquid [earned 5 cycles]
View Answer
Voters
Profile icon
PeterHLin
Profile icon
fy4l
Profile icon
HasheeshEater
Profile icon
SEIGE
Profile icon
Combustion
Profile icon
Glare
Comments
hotnewtop
Profile icon
DynamicSquid

In the .replit file, do:

run="g++ -o <exe file> <file>"

So for example if you're trying to run test.cpp, then you would do:

g++ -o test test.cpp
Profile icon
Glare

@DynamicSquid So I would have to change this I want to run another .cpp file?

Profile icon
DynamicSquid

@Glare yes

Profile icon
DynamicSquid

@Glare show me your code, I could take a look at it

Profile icon
Glare

@DynamicSquid I sent an invite

Profile icon
Coder100

repositories don't run programs...

do you mean repl?
Next time just commit the .replit file:

run="g++ <file>.cpp"

Where <file> is the cpp file.

Does that help?

EDIT: I read your question wrong

Here is the run command:

g++ main.cpp ; ./a.out

Now, I am assuming you are trying to run the main.cpp file, but if you want to configure what gets run each time:

echo -e "enter in files" files ; g++ $files ; ./a.out
Profile icon
Glare

@Coder100 Sorry, that's what I meant. Yes, thanks a lot for your help :)

Profile icon
Coder100

np :D did it work? @Glare

Profile icon
GabrieleBoccaru

@Coder100 Is working, thanks!