We are building a cloud service to provide"Compilation As A Service". We have an Ubuntu 12.04 VM on Azure. We managed to install GCC on the VM as well. Now we are building the frontend on Visual Studio. In that we have a text box which would hold the code. But we are unable to figure out how to use GCC to process the code?
Currently we are using something like this;
string log = @"C:\log.c";
using (FileStream fs = new FileStream(log, FileMode.Create))
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.Write(TextBox1.Text);
sw.Close();
}
}
string szMgwGCCPath = "/usr/bin/gcc"; // Example of location
string szArguments = " -c log.c -o log.exe"; // Example of arguments
ProcessStartInfo gccStartInfo = new ProcessStartInfo(szMgwGCCPath, szArguments);
gccStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(gccStartInfo);
I am not sure what parts of it is right. Since we are unable to test it as the compiler is stored on the clod.
string szMgwGCCPath = "/usr/bin/gcc"; // Example of location
How do we give the location? Do we use the blob storage URL? How to do that?
How do we process the file after that?
Your scenario above is not clear.
Before we go any further, your code above is being written in C#. As per the .NET Framework Design Guidelines, *please don't use Hungarian notation * It's unnecessary and largely meaningless in .NET (e.g. sz == 'string of chars ending in zero' is NOT how strings are represented in the CLR!).
Back to your code & scenario:
Where is your 'front-end' code running? WinForms/WPF client app? In an ASP.NET website?
If your client is running in ASP.NET, are you hosting the ASP.NET website in your Linux VM using Mono (if so, please update the tags for your question to include Mono and Linux)? If you are running in Mono on Linux, then why are you trying to generate an '.exe'? '.exe' files are Windows executable - Linux executables don't typically have a '.exe' extension. And if your client is running on Linux, why are you using MinGW? That's used for running GNU code on Windows!
Frankly, I think you need to either re-think what you're trying to achieve or re-state your scenario & question more clearly.