I want to programmatically compile C code from C #. I am trying, but have not yet found a solution. Here is my code.
try {
var info = new ProcessStartInfo {
FileName = "cmd.exe",
Arguments = "mingw32-gcc -o a Test.c"
};
var process = new Process { StartInfo = info };
bool start = process.Start();
process.WaitForExit();
if (start) {
Console.WriteLine("done");
}
} catch (Exception) {
Console.WriteLine("Not done");
}
I use VS2010 on Windows 7, and I set mingw32-gcc and the environment variable for mingw32-gcc C: \ Program Files \ CodeBlocks \ MinGW \ bin
Any help would be greatly appreciated. Thanks in advance.
source
share