tags:

views:

191

answers:

1

I'm trying to compile a C code in a file from a program in C++. When I run my program it call the Tiny C Compiler and generate a dll from the compilation of c code. I tried to do it by a lot of ways but I couldn't. Did anyone already do something like this?

Thanks

+2  A: 

What platform are you on?

On most platforms, you can use the C standard library's system() function to launch a separate process from your C++ program.

#include <stdlib.h>

int main (int argc, char *argv[])
{
   system ("tcc -o myproc a.c");
   return 0;
}

This will block until the spawned process exits.

On Windows, if you're not concerned about portability, you can use CreateProcess().

Nick Meyer