I want to create a program that modifies another c++ source,compiles it and runs the exe. I mean with something like gcc may be I can but on a windows os gcc may not be present. Is it possible?
-
What if you pack the compiler as part of your app (in fact it is)... is it feasible?helios– helios2010-09-02 15:14:04 +00:00Commented Sep 2, 2010 at 15:14
-
it's possible but I don't like that variant.However it seems the only way on Windows...Alexander Ivanov– Alexander Ivanov2010-09-02 15:41:24 +00:00Commented Sep 2, 2010 at 15:41
-
I think with a platform like Windows, you just can't ensure if a compiler is available, sadly.Robb– Robb2010-09-02 15:46:47 +00:00Commented Sep 2, 2010 at 15:46
-
You can't be sure of having a compiler on *nix either.Greg Domjan– Greg Domjan2010-09-02 16:30:31 +00:00Commented Sep 2, 2010 at 16:30
-
If your program should be self-contained (in the sense that some Java development environments can produce executables which basically contain a complete java runtime) my gut feeling is that a virtual machine may be the only way to go. Or perhaps you could zip the development environment (libs, headers, preprocessor, compiler, linker) and unpack it on the target as part of the installation. (Seems to be what Helios had in mind too.)Peter - Reinstate Monica– Peter - Reinstate Monica2014-08-24 03:51:46 +00:00Commented Aug 24, 2014 at 3:51
Add a comment
|
2 Answers
Cowboy answer:
Only if:
- the source code doesn't need a lot of files/headers/libraries
- they can be easily collected by your application
- the application have connection with some server of yours
The application could:
- collect the files in a zip
- send them over the wire to an compiler service (accesible vía HTTP)
- the server compile it with its own installation
- and return the binary executable inside the response.
Of course: it depends on so many variables that seems not very feasible. And the zip+http thing could be difficult from a C/C++ app.
4 Comments
Alexander Ivanov
hmm it can be slow...and it depends on internet connection. But it's interesting idea ;)
helios
Thanks... anyway I was thinking on it and realized about managing zip and http in C... and it was not that nice... :S
Steve Jessop
You can (should) grab a library for that sort of thing. Even so it's going to be more work than some languages. As it happens I have implemented both HTTP client and zip file writer libraries in the past: not in C but in a language at about the same level, so I was sitting on top of zlib and a Berkely-style sockets interface. I don't really recommend it, for a very simple http client it's not all that difficult, just very tedious. Use libcurl and libtar instead (tar since compression isn't actually essential here anyway, so keep it simple)...
Peter - Reinstate Monica
The idea is actually awesome. And some internet (well, LAN) connections are faster than disk access.