0

I wonder if there is a way to make a .exe that gives the compiler (I use Visual Studio) commands.

For example:

I have main.cpp . And I want to compile main.cpp without opening the IDE or the console. So I start a program X.exewhich gives a command to the compiler to compile main.cpp.

I heard of Makefiles and Batchfles. But I dont't know how to give other programs commands (if this is even possible). Basically I want to automate compiling.

Thank you in advance.

sepp2k
  • 363,768
  • 54
  • 674
  • 675
  • are you asking if there is a command line compiler with VS? https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019 – pm100 Apr 30 '20 at 20:28
  • Depends on your build system, but yes lots of ways to do this `cmake --build ...` and `msbuild foo.sln ....` and `make -f foo ...` – Cory Kramer Apr 30 '20 at 20:29
  • 1
    The Visual Studio C++ compiler have a command-line program, called `cl.exe`. You can call it any way you would call any other program (e.g. `system`, `ShellExecute`, `CreateProcess`). – Some programmer dude Apr 30 '20 at 20:30
  • if you're using visual studio code then your exe file is automatically created inside your project folder/ Debug with the project_name.exe – psycho developer Apr 30 '20 at 20:33
  • Yes, you want to invoke the compiler program (cl.exe) from your code. Look into how to spawn a process from C++. Note that it's simpler to do this from other languages. If you look at the Build pane in the VS Output Window, you'll see the command-line arguments that are passed to cl.exe. – Cameron Apr 30 '20 at 20:45

0 Answers0