Search code examples
c++githubrepositoryreplit

Compiling C++ repl May 2020


Compiling C++ repl

I wonder whether you can help.

I am working through the FreeCodeCamp tutorial on C++ and I am using repl.it as an online IDE.

https://www.freecodecamp.org/news/the-c-plus-plus-programming-language/

  • The "+new repl" command and choosing a langauage C++ works just fine.

Since I wanted to create a Repl linked to a Github repo, which I thought migth be a good thing to keep both up-to-date, it seems it autocreates a ".replit" file alongside the main.cpp file. The default .replit file which contains two lines:

language="cpp" 
run=""

Which won't compile and the error is:

'run' isn't configured in the .replit file try adding 'run = "echo
hello word"' to .replit

I read this: "Configuring the run button / .replit" in the Docs section https://docs.repl.it/repls/dot-replit

I went back to creating a new Repl, looking at the output when it's run successfully (a new C++ Repl, unlinked to Github, trying to guess what's the default run="" for a C++ Repl), then copied a line from the terminal output and made my .replit file look like this (clang being the compiler, it seems, the rest - some necessary parameters). I haven't researched each of the parameter, so I apologise in advance.

run="clang++-7 -pthread -std=c++17 -o main main.cpp"
language="cpp"

The result is but I was expecting a Hello World print out which normally works, if I'd use a +new Repl:

clang++-7 -pthread -std=c++17 -o main main.cpp 

A screenshot from Repl.it tryingt to compile a new C++ Repl :

screenshot


Solution

  • Delete the .replit file on the and see if that resolves your problem. Check this image for reference: Image reference