You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/windows/walkthrough-creating-a-standard-cpp-program-cpp.md
+19-12Lines changed: 19 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Walkthrough: Creating a Standard C++ Program (C++) | Microsoft Docs"
3
3
ms.custom: "get-started-article"
4
-
ms.date: "11/04/2016"
4
+
ms.date: "09/18/2018"
5
5
ms.technology: ["cpp-windows"]
6
6
ms.topic: "conceptual"
7
7
f1_keywords: ["vcfirstapp", "vccreatefirst"]
@@ -31,41 +31,48 @@ To complete this walkthrough, you must understand the fundamentals of the C++ la
31
31
32
32
1. Create a project by pointing to **New** on the **File** menu, and then clicking **Project**.
33
33
34
-
2. In the **Visual C++** project types pane, click **Windows Desktop**, and then click **Windows Console Application**.
34
+
1. In the **Visual C++** project types pane, click **Windows Desktop**, and then click **Windows Console Application**.
35
35
36
-
3. Type a name for the project.
36
+
> [!NOTE]
37
+
> For versions of Visual Studio older than 2017, in the **New Project** dialog box, expand **Installed** > **Templates** > **Visual C++**, and then select **Win32**. In the center pane, select **Win32 Console Application**.
38
+
39
+
Type a name for the project.
37
40
38
41
By default, the solution that contains the project has the same name as the project, but you can type a different name. You can also type a different location for the project.
39
42
40
43
Click **OK** to create the project.
41
44
42
-
4. If **Solution Explorer** is not displayed, on the **View** menu, click **Solution Explorer**.
45
+
> [!NOTE]
46
+
> For versions of Visual Studio older than 2017, complete the **Win32 Application Wizard**. Click **Next**, then make sure **Console Application** is selected and uncheck the **Precompiled Headers** box. Click **Finish**.
47
+
48
+
1. If **Solution Explorer** is not displayed, on the **View** menu, click **Solution Explorer**.
43
49
44
-
5. Add a new source file to the project, as follows.
50
+
1. Add a new source file to the project, as follows.
45
51
46
52
1. In **Solution Explorer**, right-click the **Source Files** folder, point to **Add**, and then click **New Item**.
47
53
48
-
2. In the **Code** node, click **C++ File (.cpp)**, type a name for the file, and then click **Add**.
54
+
1. In the **Code** node, click **C++ File (.cpp)**, type a name for the file, and then click **Add**.
49
55
50
56
The .cpp file appears in the **Source Files** folder in **Solution Explorer**, and the file is opened in the Visual Studio editor.
51
57
52
-
6. In the file in the editor, type a valid C++ program that uses the C++ Standard Library, or copy one of the sample programs and paste it in the file.
58
+
1. In the file in the editor, type a valid C++ program that uses the C++ Standard Library, or copy one of the sample programs and paste it in the file.
53
59
54
-
7. Save the file.
60
+
1. Save the file.
55
61
56
-
8. On the **Build** menu, click **Build Solution**.
62
+
1. On the **Build** menu, click **Build Solution**.
57
63
58
64
The **Output** window displays information about the compilation progress, for example, the location of the build log and a message that indicates the build status.
59
65
60
-
9. On the **Debug** menu, click **Start without Debugging**.
66
+
1. On the **Debug** menu, click **Start without Debugging**.
61
67
62
68
If you used the sample program, a command window is displayed and shows whether certain integers are found in the set.
63
69
64
70
## Next Steps
65
71
66
-
**Previous:**[Console Applications in Visual C++](../windows/console-applications-in-visual-cpp.md). **Next:**[Walkthrough: Compiling a Native C++ Program on the Command Line](../build/walkthrough-compiling-a-native-cpp-program-on-the-command-line.md).
72
+
**Previous:**[Console Applications in Visual C++](../windows/console-applications-in-visual-cpp.md)<br/>
73
+
**Next:**[Walkthrough: Compiling a Native C++ Program on the Command Line](../build/walkthrough-compiling-a-native-cpp-program-on-the-command-line.md)<br/>
67
74
68
75
## See Also
69
76
70
77
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
71
-
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)
78
+
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)<br/>
Copy file name to clipboardExpand all lines: docs/windows/walkthrough-creating-and-using-a-static-library-cpp.md
+44-25Lines changed: 44 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Walkthrough: Creating and Using a Static Library (C++) | Microsoft Docs"
3
3
ms.custom: "get-started-article"
4
-
ms.date: "07/12/2018"
4
+
ms.date: "09/18/2018"
5
5
ms.technology: ["cpp-windows"]
6
6
ms.topic: "conceptual"
7
7
dev_langs: ["C++"]
@@ -37,35 +37,44 @@ An understanding of the fundamentals of the C++ language.
37
37
38
38
1. On the menu bar, choose **File** > **New** > **Project**.
39
39
40
-
2. In the left pane of the **New Project** dialog box, expand **Installed, Visual C++**, and then select **Windows Desktop**.
40
+
1. In the left pane of the **New Project** dialog box, expand **Installed** > **Visual C++**, and then select **Windows Desktop**. In the center pane, select **Windows Desktop Wizard**.
41
41
42
-
3. In the center pane, select **Windows Desktop Wizard**.
42
+
> [!NOTE]
43
+
> For versions of Visual Studio older than 2017, in the **New Project** dialog box, expand **Installed** > **Templates** > **Visual C++**, and then select **Win32**. In the center pane, select **Win32 Console Application**.
44
+
45
+
1. Specify a name for the project—for example, *MathFuncsLib*—in the **Name** box. Specify a name for the solution—for example, *StaticLibrary*—in the **Solution Name** box. Choose the **OK** button.
46
+
47
+
- For Visual Studio 2017,
43
48
44
-
4. Specify a name for the project—for example, *MathFuncsLib*—in the**Name** box. Specify a name for the solution—for example, *StaticLibrary*—in the **Solution Name** box. Choose the **OK** button.
5. Under **Application type**, select Static Library (.lib).
51
+
1. Under **Additioal Options**, un-check the **Precompiled header** check box.
47
52
48
-
6. Under **Additional Options**, un-check the **Precompiled header**check box.
53
+
1. Choose **OK**to create the project.
49
54
50
-
7. Choose **OK** to create the project.
55
+
- For versions of Visual Studio older than 2017,
56
+
57
+
1. Click **Next**.
58
+
59
+
1. Under **Application type**, select **Static library**. Then uncheck the **Precompiled header** box and choose **Finish**.
51
60
52
61
## <aname="AddClassToLib"></a> Adding a class to the static library
53
62
54
63
### To add a class to the static library
55
64
56
-
1. To create a header file for a new class, open the shortcut menu for the **MathFuncsLib** project in **Solution Explorer**, and then choose **Add**,**New Item**. In the **Add New Item** dialog box, in the left pane, under **Visual C++**, select **Code**. In the center pane, select **Header File (.h)**. Specify a name for the header file—for example, *MathFuncsLib.h*—and then choose the **Add** button. A blank header file is displayed.
65
+
1. To create a header file for a new class, open the shortcut menu for the **MathFuncsLib** project in **Solution Explorer**, and then choose **Add** >**New Item**. In the **Add New Item** dialog box, in the left pane, under **Visual C++**, select **Code**. In the center pane, select **Header File (.h)**. Specify a name for the header file—for example, *MathFuncsLib.h*—and then choose the **Add** button. A blank header file is displayed.
57
66
58
-
2. Add a class named `MyMathFuncs` to do common mathematical operations such as addition, subtraction, multiplication, and division. The code should resemble this:
67
+
1. Add a class named `MyMathFuncs` to do common mathematical operations such as addition, subtraction, multiplication, and division. The code should resemble this:
3. To create a source file for the new class, open the shortcut menu for the **MathFuncsLib** project in **Solution Explorer**, and then choose **Add**,**New Item**. In the **Add New Item** dialog box, in the left pane, under **Visual C++**, select **Code**. In the center pane, select **C++ File (.cpp)**. Specify a name for the source file—for example, *MathFuncsLib.cpp*—and then choose the **Add** button. A blank source file is displayed.
71
+
1. To create a source file for the new class, open the shortcut menu for the **MathFuncsLib** project in **Solution Explorer**, and then choose **Add** >**New Item**. In the **Add New Item** dialog box, in the left pane, under **Visual C++**, select **Code**. In the center pane, select **C++ File (.cpp)**. Specify a name for the source file—for example, *MathFuncsLib.cpp*—and then choose the **Add** button. A blank source file is displayed.
63
72
64
-
4. Use this source file to implement the functionality for **MyMathFuncs**. The code should resemble this:
73
+
1. Use this source file to implement the functionality for **MyMathFuncs**. The code should resemble this:
5. Compile the static library by selecting **Build** > **Build Solution** on the menu bar. This creates a static library that can be used by other programs.
77
+
1. Compile the static library by selecting **Build** > **Build Solution** on the menu bar. This creates a static library that can be used by other programs.
69
78
70
79
> [!NOTE]
71
80
> When you build on the Visual Studio command line, you must build the program in two steps. First, run `cl /c /EHsc MathFuncsLib.cpp` to compile the code and create an object file that's named `MathFuncsLib.obj`. (The `cl` command invokes the compiler, Cl.exe, and the `/c` option specifies compile without linking. For more information, see [/c (Compile Without Linking)](../build/reference/c-compile-without-linking.md).) Second, run `lib MathFuncsLib.obj` to link the code and create the static library `MathFuncsLib.lib`. (The `lib` command invokes the Library Manager, Lib.exe. For more information, see [LIB Reference](../build/reference/lib-reference.md).)
@@ -76,44 +85,54 @@ An understanding of the fundamentals of the C++ language.
76
85
77
86
1. On the menu bar, choose **File** > **New** > **Project**.
78
87
79
-
2. In the left pane of the **New Project** dialog box, expand **Installed, Visual C++**, and then select **Windows Desktop**.
88
+
1. In the left pane of the **New Project** dialog box, expand **Installed** > **Visual C++**, and then select **Windows Desktop**. In the center pane, select **Windows Desktop Wizard**.
89
+
90
+
> [!NOTE]
91
+
> For versions of Visual Studio older than 2017, in the **New Project** dialog box, expand **Installed** > **Templates** > **Visual C++**, and then select **Win32**. In the center pane, select **Win32 Console Application**.
92
+
93
+
1. Specify a name for the project—for example, *MyExecRefsLib*—in the **Name** box. In the drop-down list next to **Solution**, select **Add to Solution**. This adds the new project to the solution that contains the static library. Choose the **OK** button.
94
+
95
+
- For Visual Studio 2017,
96
+
97
+
1. Under **Application type**, select **Console Application (.exe)**.
98
+
99
+
1. Under **Additioal Options**, un-check the **Precompiled header** check box.
80
100
81
-
3. In the center pane, select **Windows Desktop Wizard**.
101
+
1. Choose **OK** to create the project.
82
102
83
-
4. Specify a name for the project—for example, *MyExecRefsLib*—in the **Name** box. In the drop-down list next to **Solution**, select **Add to Solution**. This adds the new project to the solution that contains the static library. Choose the **OK** button.
84
-
5. Under **Application type**, select **Console Application (.exe)**.
103
+
- For versions of Visual Studio older than 2017,
85
104
86
-
6. Under **Additioal Options**, un-check the **Precompiled header** check box.
105
+
1. Click **Next**.
87
106
88
-
7. Choose **OK**to create the project.
107
+
1. Make sure **Console application**is selected. Then check the **Empty Project** box and choose **Finish**.
89
108
90
109
## <aname="UseLibInApp"></a> Using the functionality from the static library in the app
91
110
92
111
### To use the functionality from the static library in the app
93
112
94
113
1. After you create a console app, an empty program is created for you. The name for the source file is the same as the name that you chose earlier. In this example, it's named `MyExecRefsLib.cpp`.
95
114
96
-
2. Before you can use the math routines in the static library, you must reference it. To do this, open the shortcut menu for the **MyExecRefsLib** project in **Solution Explorer**, and then choose **Add** > **Reference**.
115
+
1. Before you can use the math routines in the static library, you must reference it. To do this, open the shortcut menu for the **MyExecRefsLib** project in **Solution Explorer**, and then choose **Add** > **Reference**.
97
116
98
-
3. The **Add Reference** dialog box lists the libraries that you can reference. The **Projects** tab lists the projects in the current solution and any libraries that they contain. On the **Projects** tab, select the **MathFuncsLib** check box, and then choose the **OK** button.
117
+
1. The **Add Reference** dialog box lists the libraries that you can reference. The **Projects** tab lists the projects in the current solution and any libraries that they contain. On the **Projects** tab, select the **MathFuncsLib** check box, and then choose the **OK** button.
99
118
100
-
4. To reference the `MathFuncsLib.h` header file, you must modify the included directories path. In the **Property Pages** dialog box for **MyExecRefsLib**, expand the **Configuration Properties** node, expand the **C/C++** node, and then select **General**. Next to **Additional Include Directories**, specify the path of the **MathFuncsLib** directory or browse for it.
119
+
1. To reference the `MathFuncsLib.h` header file, you must modify the included directories path. In the **Property Pages** dialog box for **MyExecRefsLib**, expand the **Configuration Properties** node, expand the **C/C++** node, and then select **General**. Next to **Additional Include Directories**, specify the path of the **MathFuncsLib** directory or browse for it.
101
120
102
121
To browse for the directory path, open the property value drop-down list, and then choose **Edit**. In the **Additional Include Directories** dialog box, in the text box, select a blank line and then choose the ellipsis button (**...**) at the end of the line. In the **Select Directory** dialog box, select the **MathFuncsLib** directory and then choose **Select Folder** button to save your selection and close the dialog box. In the **Additional Include Directories** dialog box, choose the **OK** button, and then in the **Property Pages** dialog box, choose the **OK** button to save your changes to the project.
103
122
104
-
5. You can now use the `MyMathFuncs` class in this app. To do this, replace the contents of `MyExecRefsLib.cpp` with this code:
123
+
1. You can now use the `MyMathFuncs` class in this app. To do this, replace the contents of `MyExecRefsLib.cpp` with this code:
6. Build the executable by choosing **Build** > **Build Solution** on the menu bar.
127
+
1. Build the executable by choosing **Build** > **Build Solution** on the menu bar.
109
128
110
129
## <aname="RunApp"></a> Running the app
111
130
112
131
### To run the app
113
132
114
133
1. Make sure that **MyExecRefsLib** is selected as the default project by opening the shortcut menu for **MyExecRefsLib** in **Solution Explorer**, and then choosing **Set as StartUp Project**.
115
134
116
-
2. To run the project, on the menu bar, choose **Debug** > **Start Without Debugging**. The output should resemble this:
135
+
1. To run the project, on the menu bar, choose **Debug** > **Start Without Debugging**. The output should resemble this:
117
136
118
137
```Output
119
138
a + b = 106.4
@@ -125,4 +144,4 @@ An understanding of the fundamentals of the C++ language.
125
144
## See Also
126
145
127
146
[Walkthrough: Creating and Using a Dynamic Link Library (C++)](../build/walkthrough-creating-and-using-a-dynamic-link-library-cpp.md)<br/>
Copy file name to clipboardExpand all lines: docs/windows/walkthrough-creating-windows-desktop-applications-cpp.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Walkthrough: Create a traditional Windows Desktop application (C++) | Microsoft Docs"
3
3
ms.custom: "get-started-article"
4
-
ms.date: "06/12/2018"
4
+
ms.date: "09/18/2018"
5
5
ms.technology: ["cpp-windows"]
6
6
ms.topic: "conceptual"
7
7
dev_langs: ["C++"]
@@ -107,7 +107,7 @@ Next, you'll learn how to create the code for a Windows desktop application in V
107
107
For information about the parameters and return value of this function, see [WinMain entry point](https://msdn.microsoft.com/library/windows/desktop/ms633559).
108
108
109
109
> [!NOTE]
110
-
> What are all those extra words, such as `CALLBACK`, or `HINSTANCE`, or `_In_`? The traditional Windows API uses typedefs and preprocessor macros extensively to abstract away some of the details of types and platform-specific code, such as calling conventions, **__declspec** declarations, and compiler pragmas. In Visual Studio, you can use the IntelliSense [Quick Info](/visualstudio/ide/using-intellisense#quick-info) feature to see what these typedefs and macros define. Hover your mouse over the word of interest, or select it and press ctrl-K, ctrl-I for a small pop-up window that contains the definition. For more information, see [Using IntelliSense](/visualstudio/ide/using-intellisense). Parameters and return types often use *SAL Annotations* to help you catch programming errors. For more information, see [Using SAL Annotations to Reduce C/C++ Code Defects](/visualstudio/code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects).
110
+
> What are all those extra words, such as `CALLBACK`, or `HINSTANCE`, or `_In_`? The traditional Windows API uses typedefs and preprocessor macros extensively to abstract away some of the details of types and platform-specific code, such as calling conventions, **__declspec** declarations, and compiler pragmas. In Visual Studio, you can use the IntelliSense [Quick Info](/visualstudio/ide/using-intellisense#quick-info) feature to see what these typedefs and macros define. Hover your mouse over the word of interest, or select it and press **Ctrl**+**K**, **Ctrl**+**I** for a small pop-up window that contains the definition. For more information, see [Using IntelliSense](/visualstudio/ide/using-intellisense). Parameters and return types often use *SAL Annotations* to help you catch programming errors. For more information, see [Using SAL Annotations to Reduce C/C++ Code Defects](/visualstudio/code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects).
111
111
112
112
1. Windows desktop programs require <windows.h>. <tchar.h> defines the `TCHAR` macro, which resolves ultimately to **wchar_t** if the UNICODE symbol is defined in your project, otherwise it resolves to **char**. If you always build with UNICODE enabled, you don't need TCHAR and can just use **wchar_t** directly.
0 commit comments