c# - How to Integrate C++ compiler in Visual Studio 2008 -


Can anyone help me with this issue?

I am currently working on my project for my final year, graduation degree. And we are developing an application to evaluate the student's programming assignment (for the first year student level)

I just use the C ++ compiler by using the C + code in the C ++ compiler I want to know about integrating.

In our case, we are loading a student C ++ code in text area, then by clicking on the button we want to compile the code. And if there are any compilation errors, then it will be displayed around the text area. (The interface is attached to it.)

And finally it is able to execute the code if there are no compilation errors and the results will be displayed in the console.

We were able to do this with the code using the inbuilt compiler using the code C # (the C # code will be loaded in the C ++ code code area). But still are not able to do the C # code.

Can someone recommend a way to do this? VS to external compiler Is it possible to integrate into the C # code? If possible, how to get it?

Will anyone contribute in solving this matter?

This is the code for the Build button, which we proceed with the C # code compilation

the codeod provider code provider = CodeDomProvider.CreateProvider ("csharp"); String output = "out.exa"; Button button object = (button) sender;

  rtbresult.Text = ""; System.CodeDom.Compiler.CompilerParameters parameter = new compiler parameter (); // Make sure that we generate an EXE, and not generate DLL parameters. GenerateExecutable = true; Parameters.OutputAssembly = Output; Compiler results result = code provider CompaleApender Complete source (criteria, RTBcode text); If (Results :Air.Count> gt; 0) {rtbresult.Forecolor = Color.Red; CompileError CompErr in foreach (results.Errors) {rtbresult.Text = rtbresult.Text + "Line Number" + CompErr.Line + ", Error Number:" + CompErr.ErrorNumber + "," "+ CompErr.ErrorText +"; " + Environment. New Line + Environment. NewLine; }} Else {// Successful compilation rtbresult.Forecolor = Color.Blue; Rtbresult.Text = "success!"; // If we click run, then launch our EXE (ButtonObject.Text == "Run") process. Start (output); // Run button} 

Unfortunately no default implementation for CodeDom for C ++ No, you can always define yourself if you want to use the same code as above to compile C ++.

Or you can call directly cl.exe, in both cases, you must manually implement cl.exe

This is difficult Do not call the code in a temporary file, cl.exe pipes you want (or do not) any output and check any output, if an exe is produced, check that its The compilation is successful and you can run the exe, if not it failed and the error made by you first E must be in the log.

It is less structured than the above, but this is the easiest way.

- More detailed

The following codes assume that your EnvironmentWorse is set correctly.

  square cl {private pronoun string clue = @ "cl. Exe"; Private prong string exe = "test.exe", file = "test.cpp"; Private string logic; Public cl (string [] args) {this.args = String.Join ("", args); This.args + = (args.Length & gt; 0? "": "") + "/ Fe" + exe + "+ + file;} public boolean compile (String content, ref string errors) {// any remove old copies if (file. Axis (XE)) file. Delete (exe); If (File.Exists (file)) file. Delete (file); file. write the text (file contents); process proc = new process (); ProckStartInfokUseShellExecute = False; ProckStartInfokRedirectStandardOutput = true; Proc.StartInfo.RedirectStandardError = true; Proc.StartInfo.FileName = Clense; Proc.StartInfo.Arguments = this.args; Proc.StartInfo .CreateNoWindow = True; proc.St Art (); // errors = = proc.StandardError.ReadToEnd (); Errors + = proc.StandardOutput.ReadToEnd (); proc.WaitForExit (); Bull success = file.exis (xi); return success;}}  

This will compile the code given to it, but this is just a sample, every compilation is successful, a file will be "Test.exe", which you can run. If the error fails, the error message will be in the "Errors" variable.

Hope this is helpful, for more information about running processes


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -