Alexander Ivanov
Alexander Ivanov

Reputation: 532

How can I compile C++ code using another C++ program?

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?

Upvotes: 1

Views: 222

Answers (2)

helios
helios

Reputation: 13841

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.

Upvotes: 2

Robb
Robb

Reputation: 2686

I think your options are fairly limited for windows:

  1. Check for an install of a compiler (possibly limit this to a short list) and use that compiler
  2. Bring along a compiler in your application's install package

Upvotes: 2

Related Questions