Program to generate C++ code and compile it.


I am currently working on an encryptor/decryptor. I want it to work in the following way:

1: You start the encryptor in CMD and give it an argument for which file should be encrypted.
2: The encryptor encrypts the file according to the argument.
3 - here comes the hard part:

The third step is to generate the key/decryptor, which will be used to decrypt the encrypted file. This key contains information about which file this specific key should encrypt and how it should be encrypted. I want this key to be an exe-file or a C++-program itself, that is generated by the encryptor.

How do I generate C++ code and compile it from another program that is already running? I want this to be portable and work on most Windows 7 machines.
My current thought is to first simply write the code from the program and then send a command to Windows cmd that then compiles it. But different computers will have different compilers, won't they? So how do I do this? :S

Ofcourse I meant that the key decrypts.
Last edited on
closed account (Dy7SLyTq)
you can always use write to file on fstream and use system to compile, but honestly i think making a basic ml-like generator would be better. dont use ml itself, as its os specific, but you could use binary or hex
Not sure if you can generate C++ code, compile it and run it from a single program (unless it is an actual compiler). Your best bet for this is to use a scripting language. Lua, python, ruby, even Javascript. These are interpreted languages which are designed to be compiled at runtime, line-by-line.
Last edited on
closed account (Dy7SLyTq)
Yes you can write and compile via a source file. And what do you mean use a real compiler? And how would a scripting language be even better?
Topic archived. No new replies allowed.