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.
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.
Browser other questions tagged php c c++ website compilers
You are not signed in. Login or sign up in order to post.
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 exampleexec("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...).– Anthony Accioly
in fact what I intended was to copy the file and spit it out to the client
– Jefter Rocha
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?
– Anthony Accioly
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?– Luiz Vieira
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.
– Higor Alves