Contents
Online compilers can be useful tools to quickly compile a snippet of code without having to install a proper compiler on our computer. They can be especially useful to play with the newest language features, to share code snippets online or to compare different compilers.
Blog posts have the tendency to rarely be updated with fresh information. Therefore, the essence of this post is available in a more up-to-date GitHub page with more compilers. If you find a compiler that’s not on the list please leave a pull request or issue on the GitHub project. The GitHub list will also leave out a few paragraphs that are purely personal opinions. Kudos also to Adi Shavit who made a huge contribution to give that page a better look.
List of online C++ compilers
The following list provides information about available online compilers and their most important features. Support for other languages than C++ is available on many of the listed websites but not covered here.
Depending on the versions of the compilers used, they support different versions of the C++ standard. See this page for more detailed feature lists. Since C++17 is not fully standardized yet, it is marked with an asterisk, where (most of) the expected C++17 features are available.
Besides mere compilation, most online compilers also execute the compiled program. The possibilities to parametrize the compilation via compiler flags, to pass command line/runtime parameters to the executed program and to provide input for standard input vary between the different compilers.
Wandbox
URL | http://melpon.org/wandbox |
Compilers | GCC 4.4.7 .. 8.0.0 (HEAD) Clang 3.1 .. 5.0.0 (HEAD) zapcc 1.0.1 |
C++ version | C++17* |
Compiler flags | dropdown selection + free text |
Runtime parameters | yes |
Stdin | yes |
Wandbox provides pretty much all of the functionality you’d want from a typical online compiler, including support for multiple files and different editor keybindings.
Besides the standard library, it features a few libraries including Boost (up to 1.64), Sprout and MessagePack. The compiled programs run in a sandbox environment that allows file I/O.
The snapshot versions of GCC and Clang that are provided make it possible to play with the latest C++17 features.
I have used Wandbox extensively in the last months, especially to verify code samples from a C++17 book that I had the pleasure to review. Since it has HEAD revisions of both Clang and GCC available, almost every of the C++17 features I tested did compile. Therefore, Wandbox is currently my go-to online compiler when I want to execute the compiled program.
Compiler Explorer (Godbolt)
URL | http://godbolt.org |
Compilers | GCC 4.4.7 .. 8.0.0 (snapshot) Clang 3.0 .. 5.0.0 (trunk) MSVC 19/2017 (x86, x64) icc 13, 16, 17 zapcc 190308 PowerPC gcc 4.8, PowerPC 64 6.3.0 MSP430 gcc 4.5.3 .. 6.2.1 MIPS gcc 5.4 (32/64 bit, el) elcc 0.1.33, 0.1.34 AVR gcc 4.5.4, 4.6.4 ARM64 gcc 5.4 ARM gcc 4.5.4 .. 5.4.1 ARM CL 2017 RTW |
C++ Version | C++17* |
Compiler flags | free text |
Runtime parameters | N/A |
Stdin | N/A |
Compiler Explorer is a compile-as-you-type IDE with a unique feature as it presents the assembly produced by the compilers. The resulting assembler can be color-mapped to the originating C++ code. It supports the use of different sources and multiple compilers at the same time, so we can compare the assembly produced by different code and/or different compilers, optimization flags, etc.
Compiler explorer can be found on GitHub and can be used locally.
Currently, the compiled code can not be executed, but there is an open GitHub issue for this feature.
I am continuously amazed by this tool and it’s ease of use. The almost instant compilation, while you type, give the immediate feedback you usually only get from large IDEs. I used Compiler Explorer a lot lately to play around with compile time calculations and to reproduce and reduce a compiler bug or two. It is no wonder that “godbolting some code” has become a term used in certain circles.
Coliru
URL | http://coliru.stacked-crooked.com |
Compilers | GCC 4.6 .. 7.1 Clang 3.8 |
C++ Version | C++17* |
Compiler flags | free text |
Runtime parameters | free text |
Stdin | via linux shell pipe |
Coliru provides an editor and a freely editable Linux shell command line, which makes it relatively powerful. For example, you can compare the outputs of both Clang and GCC by issuing the commands for compilation and execution for both compilers. Editing of multiple files at once is not supported, but since the code you share is saved in an archive you can use that to prepare multiple files (see the FAQ for an example). It is also possible to download e.g. a Gist via curl
before the compilation.
Coliru provides a public API, so it can, for example, be integrated into websites cppreference.com, which uses Coliru for its runnable examples.
Directly after Wandbox, Coliru is the other compiler I use to execute C++ code online. The slightly less up-to-date compilers and the awkward way you have to deal with multiple files if you need them make it inferior to Wandbox in my opinion. However, if these two points are not an issue for you, the free parametrization via the shell commands is a big plus.
Rextester
URL | http://rextester.com/ |
Compilers | GCC 5.4.0 Clang 3.8.0 MSVC 19/2017 |
C++ Version | C++14 |
Compiler flags | free text |
Runtime parameters | none |
Stdin | yes |
Rextester is a standard online IDE that allows to edit, compile, execute and share single C++ files. As a distinguishing feature, it allows creating live editing sessions so that multiple people can edit the same source simultaneously and see each other’s edits in real time.
Ideone
URL | https://ideone.com/ |
Compilers | GCC 6.3.0 |
C++ Version | C++14 |
Compiler flags | fixed |
Runtime parameters | none |
Stdin | yes |
Ideone is a standard online IDE that allows to edit, compile, execute and share single C++ files.
Visual C++ Compiler Online
URL | http://webcompiler.cloudapp.net/ |
Compilers | MSVC 19/2017 (x86) |
C++ Version | C++14 |
Compiler flags | reduced set |
Runtime parameters | yes |
Stdin | no |
Microsoft’s showcase for its most up-to-date compiler. It allows single file compilation, running the executable after compilation is optional.
Update: This online compiler seems to have been offline for some time now.
C++ Shell
URL | http://cpp.sh/ |
Compilers | GCC 4.9.2 |
C++ Version | C++11, partially C++14 |
Compiler flags | reduced set |
Runtime parameters | no |
Stdin | static or interactive |
Another single file compilation IDE, but with the rare feature of interactive stdin input. The web application seems to hang sometimes during compilation or execution.
Tutorialspoint CodingGround
URL | https://www.tutorialspoint.com/compile_cpp11_online.php |
Compilers | GCC 4.8.5 |
C++ Version | C++11 |
Compiler flags | yes |
Runtime parameters | no |
Stdin | yes |
An online IDE with multiple files. The whole web application seems to be sluggish at times, I could not register to try out the features that require an account login like saving or uploading whole projects (broken link/unresponsive web app).
Codepad
URL | http://codepad.org/ |
Compilers | GCC 4.1.2 |
C++ Version | C++03 |
Compiler flags | fixed |
Runtime parameters | no |
Stdin | no |
Codepad can be unintuitive – pasting new code at theURLof previously pasted code will return to the original code. The code will be compiled and executed as-is without any possibility to further parametrize it.
LoopPerfect C++ Fiddle
URL | http://fiddle.jyt.io/ |
Compilers | unknown |
C++ Version | unknown |
Compiler flags | N/A |
Runtime parameters | N/A |
Stdin | N/A |
C++ Fiddle claims to be an interactive C++ interpreter/terminal but seems to be broken, or the interface is so non-obvious that is should be considered broken.
Conclusion
With the triplet of Wandbox, Compiler Explorer and Coliru there is not much left to want from online compilers. The Tutorialspoint online IDE is an honorable mention as it might feel like a good idea. However, in my opinion, it’s overkill and the sluggish performance of the web app does not make up for fancy features you’d rarely need for one-off code snippets.
Permalink
There is also a nice online compiler, it also compatible to run from a smartphone https://onlinecompilers.com/online-cpp-compiler
Permalink
Thanks for maintaining the list. All of the entrants in the list have standout features with the addition of certain foibles, for want of a better term. Started off liking C-Shell with its uncluttered gui, and stdIn, the only drawback is that it is still in C14 land. The top three picks are a must for everyone, in my case of compiling small C++ code, probably Wandbox is the best choice.
Permalink
There is also https://ide.judge0.com.
Permalink
Thanks! I’ll have a look at it and add it to the GitHub page.
Permalink
One more online compiler: https://paiza.io/en/languages/online-cpp-compiler
Permalink
Hi, please refer to the link to the Github pages, there you’ll find a mention of paiza.io. The blog post is not updated when I am made aware of new compilers.
Permalink
it looks like http://webcompiler.cloudapp.net/ is down.. or mabe even closed? it was a nice way to play with the latest MSVC as I remember.
Permalink
Yes, I got that one as an issue on the GitHub page a while ago. Hasn’t reappeared for months 🙁
Permalink
There is also a really nice project: http://quick-bench.com
Permalink
Hi Aleksander, thanks for your comment. I added quick-bench to the GitHub.io page.
Permalink
Hi Arne, indeed, I have not read the whole article carefully and simple ctrl+f was not able to help me locating the updated external resource.
Permalink
I imagine. I made it more prominent for others 🙂
Permalink
Permalink
Permalink
nice list!
Do you know how to add such compiler into your site?
That would be great if an online compiler could be called somehow from your article.
for example cppreference uses such approach to make runnable code. It uses Coliru.
Any webdev hacker interested in creating a guide how to add something similar to other sites? 🙂
Permalink
I haven’t looked into that yet. IIRC Coliru has a short API description. You could probably also just ask StackedCrooked on Stackoverflow (he’s often in the C++ chatroom there) or have a look at how cppref does the integration.
Permalink
One way is to add the Javascript from https://github.com/alamaison/coliru and intialize it with : window.onload = coliru.addRunButtons
Permalink
Another one that’s missing: http://code.geeksforgeeks.org/
Permalink
Less descriptive list is available at https://isocpp.org/get-started too. One can also ssh to an openshift gear for more customized programs. Codenvy workspaces can allow us to collaborate on remote work too. Most competitive programming websites like Code Gladiator Techgig, … also have not only C++ enabled, but language wise benchmark the best execution times so you can see how much efficient the resulting leading (if not also winning) program for each language is on their infrastructure/platform. IIRC, you can try their editor with your sample code before competing.
Permalink
Thanks Arne!
What I like in wandbox is that there is support for the range-v3 library. And Ideone has many other languages integrated, which is cool.
Did you find that online compilers generally have support for boost? You mentionned it for wandbox, and I know that Coliru does have it too, but I’m not sure about the others.
Permalink
I found it mentioned on Wandbox, did not check the others though. When I find time I could run a little program that prints the boost version and improve the GitHub page. – or someone sends a pull request 😉
Permalink
The one thing I’ve found lacking in Wandbox is the ability to pass -E -P to the compiler. The site fills in enough of the command line for you that I haven’t been able to get that working. Of course Coliru takes care of this pretty well, especially considering that latest and greatest preprocessor features aren’t usually a thing (though it looks like VA_OPT might be soon).
Permalink
I guess
-E
does not make much sense in the context of a tool that tries to execute the code generated by the compiler. You can pass-P -E
, and without having the site filling out anything else of the command line except the source file: https://wandbox.org/permlink/TYXgg1xFYznG0k8kThe problem is that Wandbox will try to execute the result which is not executable code. I think for more exotic things than simply executing the code, Godbolt and Coliru are the right tools.
Permalink
Missing: https://tio.run/nexus
Do you know a single C++ file compilation (offline) Android app?
Permalink
I doubt that such an app would be feasible. An offline app would need a full C++ compiler which is a rather large and resource hungry program for a mobile device. In addition, typing C++ code on a mobile device is not much fun.
Permalink
I am using termux for offline compiling of C++ on an Android phone. One thing I’m having trouble with is getting profiling working though.
Permalink
I wasn’t aware of termux, sounds promising. Thanks for pointing me to it! 🙂