Compile a .cpp file to an EXE inside of a program (EXE file) [closed]
I want to make a program (EXE file) that will take the user defined settings and开发者_如何学Python make a custom (EXE) file for the user inside of the previously mentioned program (EXE). Is there like a portable GCC or something?
Please be as detailed as possible. I am not really sure where to start with this one.
The compiler itself is just another program which reads some input (source code) and writes some output (object code, or executable if it runs the linker too). You can use something like the system()
call to execute a compiler, for example with gcc:
system("g++ -o test test.cpp");
That will run the compiler (g++
), telling it to create an output file with a specific name (-o test
) using the named source file (test.cpp
).
Your best bet for this is to use an embedded resource - then use e.g. BeginUpdateResource and related functions to modify a precreated EXE file. The MSDN overview of resources contains the information you need to add a RT_RCDATA
block to your EXE, retrieve its contents run-time, and modify its contents from another program.
精彩评论