Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile a C++ File without making a project in Visual Studio 2017?

Tags:

c++

projects

I want to compile a C++ source file without making a project in visual studio 2017 without making a project like we do in some code editors, how can I do that. Can anyone please tell?

Here is an example, in sublime text, I create a code and then compile it by ctrl + b.In a similar manner, I want to do that in visual studio 2017.

like image 354
WildFire Avatar asked May 18 '18 07:05

WildFire


2 Answers

You can open "Developer Command Prompt for VS2017" at the start menu and use cl.exe to compile your source code.

E.g. c++ source file name: test.cpp
type "cl test.cpp"
Then, it will generate "test.obj" and "test.exe" if no bugs found.

You can type "cl" for simple usage and "cl /?" for complete help.

like image 20
Patrick Avatar answered Oct 09 '22 02:10

Patrick


You can open a folder and start coding in visual studio without creating a project or solution file.

They call it the Open Folder feature.

Visual Studio 2017 introduces the "Open Folder" feature, which enables you to open a folder of source files and immediately start coding with support for IntelliSense, browsing, refactoring, debugging, and so on. No .sln or .vcxproj files are loaded...

from the main menu select File | Open | Folder or press Ctrl + Shift + Alt + O.

The easiest way I found from there is to right click in the "Solution Explorer" area and select "Open Developer Command Prompt". From there you can use cl to compile your program however you see fit.

like image 184
Increasingly Idiotic Avatar answered Oct 09 '22 00:10

Increasingly Idiotic