使用 C# 以编程方式编译生成的 .cpp 文件?
Programatically compile generated .cpp file with c#?
我使用 c# 以编程方式生成了一个 .cpp 文件,并将其另存为 a.cpp 中的 "D:\" 。
我的问题是如何使用 visual studio?
之类的东西在 C# 中以编程方式编译此文件
假设你有 VS 安装程序,你可以使用 cl.exe 编译你的 C++ 文件,这是 MS C++ 编译器。
要从 C# 执行此操作,您需要启动一个进程:
var proc = new Process();
proc.StartInfo.FileName = "cl.exe" // bear in mind you actually need the full path
proc.StartInfo.Arguments = "..." // that would be your cpp file and probably some switches
proc.Start();
proc.WaitForExit(); // call only if you would like that the program execution waits untill that process finishes
我使用 c# 以编程方式生成了一个 .cpp 文件,并将其另存为 a.cpp 中的 "D:\" 。 我的问题是如何使用 visual studio?
之类的东西在 C# 中以编程方式编译此文件假设你有 VS 安装程序,你可以使用 cl.exe 编译你的 C++ 文件,这是 MS C++ 编译器。
要从 C# 执行此操作,您需要启动一个进程:
var proc = new Process();
proc.StartInfo.FileName = "cl.exe" // bear in mind you actually need the full path
proc.StartInfo.Arguments = "..." // that would be your cpp file and probably some switches
proc.Start();
proc.WaitForExit(); // call only if you would like that the program execution waits untill that process finishes