Well, I've been using Dev-C++ for a while for learning the language [c++], and some stuff wouldn't work properly, like global and local variables. Then I decided to download Microsoft Visual C++ to see how it compared, and it was absolutely great; especially with its aesthetics. One thing that has bothered me, though, is that since I need to make lots of small source files to test out things I've learned, I have to make a large project file each and every time, which take up ~18mb of space. I have tried to just make a source C++ file, but it never works since the compile and run buttons don't highlight without a project file, and pressing f5 yields no result as well. But with Dev-C++, I could just open it up, control+n, and write the program quickly, compile and it'd show up, no need for a project file. So is there a way to to compile single source files in Microsoft Visual C++ without needing to make a project file to include it in?
Build and run your code in Visual Studio To build your project, choose Build Solution from the Build menu. The Output window shows the results of the build process. To run the code, on the menu bar, choose Debug, Start without debugging. A console window opens and then runs your app.
You don't need a compiler to run the executable. You compile your C code into an executable binary once. Then you can run it multiple times. Windows has already been compiled and doesn't need to be compiled by you.
The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.
For simple program, you can easily compile from command line,
Star menu->Visual Studio->Visual Studio Tools->Command Line
cd c:\..\your program path
cl.exe test.cpp
I typically make one project for temporary work and just re-use it. If you have a really desperate need to keep around your learning files, then just make one project, add new source files, and exclude all the old ones from the build. There's no need to make a new project for every temporary or learning project.
You can execute the compiler from the command line. First you will need to open a command prompt will all the VC++ environment variables set. Then you just invoke "cl" with the options you want.
If you want to stay within the IDE, then you can set up an "External Tool" to compile it for you:
Now, to use this, you must invoke Visual Studio with the correct environment variables set. One way is to launch a Visual Studio Command Prompt and then enter devenv.exe. Then open the file you want to compile and select the new tool under the Tools menu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With