I want to compile a batch file into an EXE file using C++. I can get through parsing the batch file and writing a new .cpp file. But I don’t know how to compile the new .cpp file into an EXE file for the end user.
OK, here’s the thing, I am creating an application in DevC++ that will read in a batch file. Then, one by one parsing it using:
system(getline(myfile,line));
After setting everything up, I save the newly created file as “main.cpp”.
The problem is, I want to compile it into an EXE file, from my program, for the end user.
So basically, can I compile a C++ file from a C++ EXE?
Yes, you can provided that the end user has a C++ compiler installed and you’re emitting valid C++.
Depending on the compiler you’re using, your C++ executable would have to spawn a process that runs
or a similar invocation of the compiler after finishing the translation.
If your user doesn’t have a compiler installed, then you’re pretty much out of luck – trying to build a C++ compiler yourself is a rather non-trivial exercise.