Compile C++ code via C# class in Visual Studio -
I use this method to compile a C ++ file in VS. But even I also provide the correct file which gives false returns. Can anyone help me ... this is class CL
class CL {private const string clexe = @ "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, riff string errors) {if (File. Exists (exe)) file. Delete (exe); If (File.Exists (file)) file. Delete (file); file. write the text (file contents); process proc = new process (); ProckStartInfo .UseShellExecute = false; Proc.StartInfo.RedirectStandardOutput = true; Proc.StartInfo.RedirectStandardError = true; Proc.StartInfo.FileName = Clense; Proc.StartInfo.Arguments = this.args; Proc.StartInfo.CreateNoWindow = true; proc.Start (); // errors = = proc.StandardError.ReadToEnd (); Errors + = proc.StandardOutput.ReadToEnd (); proc.Wai TForExit (): Bull success = file. Axis (XE), the success of the return;}}
It is click my button event
private void button 1_Click (Object Sender, EventArgs E) {string content = "#include" Stdio H & gt; \ N () {\ n Print (\ "Hello World \"); \ N} \ n "; string errors =" "; CL = new CL (new String [] {}); if (KkCompile (materials, referee errors)) console. WrightLine (" Success! "); Other MessageBox.Show ("Errors:", Errors);}
Your Visual Studio installation should follow the path to the folder:
VC \ bin \ x86_amd64 \ 1033 \ 1033
a vc \ bin \ x86_amd64 \ 1033
). Education must resolve.
I have a solution:
Comments
Post a Comment