1

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?

Kara
  • 6,115
  • 16
  • 50
  • 57
Rohan Rath
  • 21
  • 3
  • Are you trying to start a Linux executable within .NET? Or do you have a Windows GCC you're trying to start? – Igorek Mar 11 '13 at 03:07

1 Answers1

1

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.

Rich Turner
  • 10,800
  • 1
  • 51
  • 68
  • Sir, thank you for the answer. Let me try to tell you the scenario properly. We have to host Compiler as a Service through a .NET application. For that we are creating a Web Role application. The requirements are as follows: The User inputs the code in a text box. We pick up that text, convert it to a C file and compile it using GCC, which we have already installed on the Ubuntu VM using PuTTy. The problem is, we are not sure if this would work. We wanted to build something like ideone.com – Rohan Rath Mar 11 '13 at 09:03
  • We are not allowed to use Mono. We had to install GCC on the cloud VM and access it from the Web Role Application. And, that code was being tested on windows so was using .exe. Apologies for that misconception there. – Rohan Rath Mar 11 '13 at 09:06
  • The application will be published on azure, and will run as a cloudapp. The programs won't be stored and only a temporary c file will be made which will store the text from the textbox in the UI where the user will input the code. The GCC compiler is on the OSDisk of the VM. And the VM itself is on a blob storage. I'd like to state again that we were trying to make something like ideone.com – Rohan Rath Mar 11 '13 at 09:09