How to compile a . C/C++ on my website

Asked

Viewed 168 times

1

Is there any way to compile a file. C/C++ within a website? let’s say a "file will be generated. c" and this file will be compiled... maybe you can do this in PHP or with some add-on.

  • 2

    Hi Jefter, Voce means do something similar to what the ideone. makes? In theory you can call gcc (or some other compiler) with exec, for example exec("g++ arquivo.c", $saida);, but take great care with the security implications (attacks on the compiler) and performance (processes running for a long time or even locking...).

  • in fact what I intended was to copy the file and spit it out to the client

  • 3

    What would you like to spit at the customer exactly? The output of the compilation (errors, etc?)? Or you intend to compile, run and return what the app played on standard output? Or I would still like to compile and return the binary to the client?

  • 3

    Yes, there are many ways. For example, assuming the compiler (and the libraries it depends on) are installed on the server running PHP, you can simply use the function shell_exec. Maybe you can also implement an integration with a service like Sphere Engine of Ideone. But the choice will depend on what you intend to return to the customer, as the colleague @Anthonyaccioly well asked. Edit the question to make it clearer/specific, ok?

  • A good article that I managed to find with a few minutes of research is this Basically from what I understand you want to build an online compiler.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.