Compile .cpp file to .exe inside of Program(exe)? [closed]

爱⌒轻易说出口 提交于 2020-01-16 00:42:10

问题


Here is the deal...

I want to make a program (exe) that will take the user defined settings and make a custom (exe) file for the user inside of the previously mentioned program (exe). Wanted to know if there was like a portable gcc or something?

Please be as detailed as possible, not really sure where to start with this one.


回答1:


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).




回答2:


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.



来源:https://stackoverflow.com/questions/5689437/compile-cpp-file-to-exe-inside-of-programexe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!