title: Compiling C++ repl May 2020
body: <p>Compiling C++ repl</p>
  
  <p>I wonder whether you can help.</p>
  
  <p>I am working through the FreeCodeCamp tutorial on C++ and I am using repl.it as an online IDE.</p>
  
  <p><a href="https://www.freecodecamp.org/news/the-c-plus-plus-programming-language/" rel="nofollow noreferrer">https://www.freecodecamp.org/news/the-c-plus-plus-programming-language/</a></p>
  
  <ul>
  <li>The "+new repl" command and choosing a langauage C++ works just fine.</li>
  </ul>
  
  <p>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:</p>
  
  <pre><code>language="cpp" 
  run=""
  </code></pre>
  
  <p>Which won't compile and the error is: </p>
  
  <pre><code>'run' isn't configured in the .replit file try adding 'run = "echo
  hello word"' to .replit
  </code></pre>
  
  <p>I read this: "Configuring the run button / .replit" in the Docs section
  <a href="https://docs.repl.it/repls/dot-replit" rel="nofollow noreferrer">https://docs.repl.it/repls/dot-replit</a></p>
  
  <p>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.  </p>
  
  <pre><code>run="clang++-7 -pthread -std=c++17 -o main main.cpp"
  language="cpp"
  </code></pre>
  
  <p>The result is but I was expecting a Hello World print out which normally works, if I'd use a +new Repl: </p>
  
  <pre><code>clang++-7 -pthread -std=c++17 -o main main.cpp 
  </code></pre>
  
  <p><em>A screenshot from Repl.it tryingt to compile a new C++ Repl</em> :</p>
  
  <p><a href="https://i.stack.imgur.com/nfkQ0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nfkQ0.png" alt="screenshot"></a></p>