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
+14-13Lines changed: 14 additions & 13 deletions
Display the source diff
Display the rich diff
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,42 @@ 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
+
1. Type a name for the project.
37
37
38
38
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
39
40
40
Click **OK** to create the project.
41
41
42
-
4. If **Solution Explorer** is not displayed, on the **View** menu, click **Solution Explorer**.
42
+
1. If **Solution Explorer** is not displayed, on the **View** menu, click **Solution Explorer**.
43
43
44
-
5. Add a new source file to the project, as follows.
44
+
1. Add a new source file to the project, as follows.
45
45
46
46
1. In **Solution Explorer**, right-click the **Source Files** folder, point to **Add**, and then click **New Item**.
47
47
48
-
2. In the **Code** node, click **C++ File (.cpp)**, type a name for the file, and then click **Add**.
48
+
1. In the **Code** node, click **C++ File (.cpp)**, type a name for the file, and then click **Add**.
49
49
50
50
The .cpp file appears in the **Source Files** folder in **Solution Explorer**, and the file is opened in the Visual Studio editor.
51
51
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.
52
+
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
53
54
-
7. Save the file.
54
+
1. Save the file.
55
55
56
-
8. On the **Build** menu, click **Build Solution**.
56
+
1. On the **Build** menu, click **Build Solution**.
57
57
58
58
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
59
60
-
9. On the **Debug** menu, click **Start without Debugging**.
60
+
1. On the **Debug** menu, click **Start without Debugging**.
61
61
62
62
If you used the sample program, a command window is displayed and shows whether certain integers are found in the set.
63
63
64
64
## Next Steps
65
65
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).
66
+
**Previous:**[Console Applications in Visual C++](../windows/console-applications-in-visual-cpp.md)<br/>
67
+
**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
68
68
69
## See Also
69
70
70
-
[C++ Language Reference](../cpp/cpp-language-reference.md)
71
-
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)
71
+
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
72
+
[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
+27-26Lines changed: 27 additions & 26 deletions
Display the source diff
Display the rich diff
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,35 @@ 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**.
41
41
42
-
3. In the center pane, select **Windows Desktop Wizard**.
42
+
1. In the center pane, select **Windows Desktop Wizard**.
43
43
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.
44
+
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.
45
45
46
-
5. Under **Application type**, select Static Library (.lib).
46
+
1. Under **Application type**, select Static Library (.lib).
47
47
48
-
6. Under **Additional Options**, un-check the **Precompiled header** check box.
48
+
1. Under **Additional Options**, un-check the **Precompiled header** check box.
49
49
50
-
7. Choose **OK** to create the project.
50
+
1. Choose **OK** to create the project.
51
51
52
52
## <aname="AddClassToLib"></a> Adding a class to the static library
53
53
54
54
### To add a class to the static library
55
55
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.
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.
57
57
58
-
2. Add a class named `MyMathFuncs` to do common mathematical operations such as addition, subtraction, multiplication, and division. The code should resemble this:
58
+
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.
62
+
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
63
64
-
4. Use this source file to implement the functionality for **MyMathFuncs**. The code should resemble this:
64
+
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.
68
+
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
69
70
70
> [!NOTE]
71
71
> 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 +76,45 @@ An understanding of the fundamentals of the C++ language.
76
76
77
77
1. On the menu bar, choose **File** > **New** > **Project**.
78
78
79
-
2. In the left pane of the **New Project** dialog box, expand **Installed, Visual C++**, and then select **Windows Desktop**.
79
+
1. In the left pane of the **New Project** dialog box, expand **Installed** > **Visual C++**, and then select **Windows Desktop**.
80
80
81
-
3. In the center pane, select **Windows Desktop Wizard**.
81
+
1. In the center pane, select **Windows Desktop Wizard**.
82
82
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)**.
83
+
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.
85
84
86
-
6. Under **Additioal Options**, un-check the **Precompiled header** check box.
85
+
1. Under **Application type**, select **Console Application (.exe)**.
87
86
88
-
7. Choose **OK** to create the project.
87
+
1. Under **Additioal Options**, un-check the **Precompiled header** check box.
88
+
89
+
1. Choose **OK** to create the project.
89
90
90
91
## <aname="UseLibInApp"></a> Using the functionality from the static library in the app
91
92
92
93
### To use the functionality from the static library in the app
93
94
94
95
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
96
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**.
97
+
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
98
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.
99
+
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
100
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.
101
+
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
102
102
103
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
104
104
-
5. You can now use the `MyMathFuncs` class in this app. To do this, replace the contents of `MyExecRefsLib.cpp` with this code:
105
+
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.
109
+
1. Build the executable by choosing **Build** > **Build Solution** on the menu bar.
109
110
110
111
## <aname="RunApp"></a> Running the app
111
112
112
113
### To run the app
113
114
114
115
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
116
116
-
2. To run the project, on the menu bar, choose **Debug** > **Start Without Debugging**. The output should resemble this:
117
+
1. To run the project, on the menu bar, choose **Debug** > **Start Without Debugging**. The output should resemble this:
117
118
118
119
```Output
119
120
a + b = 106.4
@@ -124,5 +125,5 @@ An understanding of the fundamentals of the C++ language.
124
125
125
126
## See Also
126
127
127
-
[Walkthrough: Creating and Using a Dynamic Link Library (C++)](../build/walkthrough-creating-and-using-a-dynamic-link-library-cpp.md)
0 commit comments