Compiling in G++ Inside a VB.Net Program

I'd like to compile a c++ source code by calling the g++ compiler in my VB.NET program. I tried sending commands to the g++ compiler using the stream writer but it doesn't show anything. I want to display the output and the errors if there is any, without the console closing after executing the commands.

Private Sub btnBuildSolution_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuildSolution.Click

    Try

        Dim CompileProcess As New Process

        Dim startInfo As New ProcessStartInfo

        startInfo.FileName = "cmd.exe"

        startInfo.RedirectStandardInput = True

        startInfo.UseShellExecute = False

        CompileProcess.StartInfo = startInfo

        CompileProcess.Start()

        Dim streamWriter As StreamWriter = CompileProcess.StandardInput

        streamWriter.WriteLine("PATH " & System.Environment.CurrentDirectory & "\G++\MinGW\bin")

        streamWriter.WriteLine("g++ C:\Users\pseudo11\Desktop\hello.cpp")

        streamWriter.WriteLine("a.exe")

        streamWriter.WriteLine("pause")

        streamWriter.WriteLine("exit")

        streamWriter.Close()

    Catch ex As Exception

        MsgBox(ex.Message)

    End Try

End Sub

I also tried it doing like this, but to no avail.

Private Sub btnBuildSolution_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuildSolution.Click

    Try

        Dim startInfo As New ProcessStartInfo

        startInfo.FileName = "cmd.exe"

        startInfo.Arguments = "PATH " & System.Environment.CurrentDirectory & "\G++\MinGW\bin g++ C:\Users\pseudo11\Desktop\hello.cpp a.exe"

        startInfo.WindowStyle = ProcessWindowStyle.Normal

        Process.Start(startInfo)

    Catch ex As Exception

        MsgBox(ex.Message)

    End Try

End Sub

Answers


Need Your Help

app crashes after checking network reachability in iphone?

iphone mpmovieplayercontroller avaudiosession

i have a mpmovieplayercontroller to play online music and avaudiosession to play the same music at background, when the first time app launches without network access, normally i shows "no internet

Network device can be pinged but no tcp connection

c# networking windows-7 tcp tcpclient

I have built a windows service, that connects to a local network device via tcpClient, using an IP and a portnumber. The network device streams out data, that i receive an read. That has been worki...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.