Running C In A Browser
Solution 1:
Old question but for those that land in here in 2018 it would be worth looking at Web Assembly.
Solution 2:
You may want to take a look at Google Native Client, which, as described, is a sandbox for running compiled C and C++ code in the browser efficiently and securely, independent of the user’s operating system, allowing web-based applications to run at near-native speeds. It also uses a code verifier to prevent use of unsafe instructions such as those that perform system calls. Native Client provides customized versions of the GNU toolchain, specifically GCC and binutils as well as LLVM.
Apart from the official link given, you can take a look at the Wikipedia article on Google NaCL which has some more useful info.
Solution 3:
It's appallingly evil, but you may be able to compile the cint C/C++ interpreter with emscripten. That would give you a browser-only environment which can interpret (slowly) C or C++ programs.
Unfortunately, cint claims to support mixing of interpreted code with precompiled code. This means that it's going to want to do things which emscripten won't support, so you'll have to hack it.
If you're willing to restrict yourself to Chrome you may find it easier to compile cint via the NaCL plugin system, because that means you can use a real x86 toolchain. But this won't let you use a real compiler; NaCL doesn't allow the dynamic generation of machine code, so systems like tcc won't work. cint may be easier to port on this platform, though.
Post a Comment for "Running C In A Browser"