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/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,7 @@ Right now, this DLL doesn't do very much. Next, you'll create a header file to d
134
134
135
135
1. To create a header file for your functions, on the menu bar, choose **Project** > **Add New Item**.
136
136
137
-
1. In the **Add New Item** dialog box, in the left pane, select **Visual C++**. In the center pane, select **Header File (.h)**. Specify *MathLibrary.h* as the name for the header file.
137
+
1. In the **Add New Item** dialog box, in the left pane, select **Visual C++**. In the center pane, select **Header File (.h)**. Specify *`MathLibrary.h`* as the name for the header file.
138
138
139
139
:::image type="content" source="media/mathlibrary-add-new-item-header-file.png" alt-text="Screenshot of the Add New Item dialog with the C plus plus Header File template selected, and MathLibrary.h entered in the Name textbox.":::
140
140
@@ -191,11 +191,11 @@ When the `MATHLIBRARY_EXPORTS` macro is defined, the `MATHLIBRARY_API` macro set
191
191
192
192
::: moniker range=">=msvc-160"
193
193
194
-
1. In **Solution Explorer**, right-click on the **Source Files** node and choose **Add** > **New Item**. Create a new .cpp file called *MathLibrary.cpp*, in the same way that you added a new header file in the previous step.
194
+
1. In **Solution Explorer**, right-click on the **Source Files** node and choose **Add** > **New Item**. Create a new *`.cpp`* file called *`MathLibrary.cpp`*, in the same way that you added a new header file in the previous step.
195
195
196
196
1. In the editor window, select the **MathLibrary.cpp** tab if it's already open. If not, in **Solution Explorer**, double-click **MathLibrary.cpp** in the **Source Files** folder of the **MathLibrary** project to open it.
197
197
198
-
1. In the editor, replace the contents of the *MathLibrary.cpp* file with the following code:
198
+
1. In the editor, replace the contents of the *`MathLibrary.cpp`* file with the following code:
199
199
200
200
```cpp
201
201
// MathLibrary.cpp : Defines the exported functions for the DLL.
@@ -262,7 +262,7 @@ When the `MATHLIBRARY_EXPORTS` macro is defined, the `MATHLIBRARY_API` macro set
262
262
263
263
1. In the editor window, select the tab for **MathLibrary.cpp** if it's already open. If not, in **Solution Explorer**, double-click **MathLibrary.cpp** in the **Source Files** folder of the **MathLibrary** project to open it.
264
264
265
-
1. In the editor, replace the contents of the *MathLibrary.cpp* file with the following code:
265
+
1. In the editor, replace the contents of the *`MathLibrary.cpp`* file with the following code:
266
266
267
267
```cpp
268
268
// MathLibrary.cpp : Defines the exported functions for the DLL.
@@ -398,7 +398,7 @@ To avoid out-of-sync code, we recommend you set the include path in your client
398
398
399
399
1. Choose the **Create** button to create the client project.
400
400
401
-
A minimal console application project is created for you. The name for the main source file is the same as the project name that you entered earlier. In this example, it's named *MathClient.cpp*. You can build it, but it doesn't use your DLL yet.
401
+
A minimal console application project is created for you. The name for the main source file is the same as the project name that you entered earlier. In this example, it's named *`MathClient.cpp`*. You can build it, but it doesn't use your DLL yet.
402
402
403
403
::: moniker-end
404
404
@@ -414,7 +414,7 @@ A minimal console application project is created for you. The name for the main
414
414
415
415
1. Choose **OK** to create the client app project.
416
416
417
-
A minimal console application project is created for you. The name for the main source file is the same as the project name that you entered earlier. In this example, it's named *MathClient.cpp*. You can build it, but it doesn't use your DLL yet.
417
+
A minimal console application project is created for you. The name for the main source file is the same as the project name that you entered earlier. In this example, it's named *`MathClient.cpp`*. You can build it, but it doesn't use your DLL yet.
418
418
419
419
::: moniker-end
420
420
@@ -434,11 +434,11 @@ A minimal console application project is created for you. The name for the main
434
434
435
435
1. Choose the **Finish** button to create the project.
436
436
437
-
When the wizard finishes, a minimal console application project is created for you. The name for the main source file is the same as the project name that you entered earlier. In this example, it's named *MathClient.cpp*. You can build it, but it doesn't use your DLL yet.
437
+
When the wizard finishes, a minimal console application project is created for you. The name for the main source file is the same as the project name that you entered earlier. In this example, it's named *`MathClient.cpp`*. You can build it, but it doesn't use your DLL yet.
438
438
439
439
::: moniker-end
440
440
441
-
Next, to call the MathLibrary functions in your source code, your project must include the *MathLibrary.h* file. You could copy this header file into your client app project, then add it to the project as an existing item. This method can be a good choice for third-party libraries. However, if you're working on the code for your DLL and your client at the same time, the header files could get out of sync. To avoid this issue, set the **Additional Include Directories** path in your project to include the path to the original header.
441
+
Next, to call the MathLibrary functions in your source code, your project must include the *`MathLibrary.h`* file. You could copy this header file into your client app project, then add it to the project as an existing item. This method can be a good choice for third-party libraries. However, if you're working on the code for your DLL and your client at the same time, the header files could get out of sync. To avoid this issue, set the **Additional Include Directories** path in your project to include the path to the original header.
442
442
443
443
### To add the DLL header to your include path
444
444
@@ -454,7 +454,7 @@ Next, to call the MathLibrary functions in your source code, your project must i
454
454
455
455
1. Double-click in the top pane of the **Additional Include Directories** dialog box to enable an edit control. Or, choose the folder icon to create a new entry.
456
456
457
-
1. In the edit control, specify the path to the location of the *MathLibrary.h* header file. You can choose the ellipsis (**...**) control to browse to the correct folder.
457
+
1. In the edit control, specify the path to the location of the *`MathLibrary.h`* header file. You can choose the ellipsis (**...**) control to browse to the correct folder.
458
458
459
459
You can also enter a relative path from your client source files to the folder that contains the DLL header files. If you followed the directions to put your client project in a separate solution from the DLL, the relative path should look like this:
460
460
@@ -470,7 +470,7 @@ Next, to call the MathLibrary functions in your source code, your project must i
470
470
471
471
1. After you've entered the path to the header file in the **Additional Include Directories** dialog box, choose the **OK** button. In the **Property Pages** dialog box, choose the **OK** button to save your changes.
472
472
473
-
You can now include the *MathLibrary.h* file and use the functions it declares in your client application. Replace the contents of *MathClient.cpp* by using this code:
473
+
You can now include the *`MathLibrary.h`* file and use the functions it declares in your client application. Replace the contents of *`MathClient.cpp`* by using this code:
474
474
475
475
```cpp
476
476
// MathClient.cpp : Client app for MathLibrary DLL.
@@ -494,9 +494,9 @@ int main()
494
494
}
495
495
```
496
496
497
-
This code can be compiled, but not linked. If you build the client app now, the error list shows several LNK2019 errors. That's because your project is missing some information: You haven't specified that your project has a dependency on the *MathLibrary.lib* library yet. And, you haven't told the linker how to find the *MathLibrary.lib* file.
497
+
This code can be compiled, but not linked. If you build the client app now, the error list shows several LNK2019 errors. That's because your project is missing some information: You haven't specified that your project has a dependency on the *`MathLibrary.lib`* library yet. And, you haven't told the linker how to find the *`MathLibrary.lib`* file.
498
498
499
-
To fix this issue, you could copy the library file directly into your client app project. The linker would find and use it automatically. However, if both the library and the client app are under development, that might lead to changes in one copy that aren't shown in the other. To avoid this issue, you can set the **Additional Dependencies** property to tell the build system that your project depends on *MathLibrary.lib*. And, you can set an **Additional Library Directories** path in your project to include the path to the original library when you link.
499
+
To fix this issue, you could copy the library file directly into your client app project. The linker would find and use it automatically. However, if both the library and the client app are under development, that might lead to changes in one copy that aren't shown in the other. To avoid this issue, you can set the **Additional Dependencies** property to tell the build system that your project depends on *`MathLibrary.lib`*. And, you can set an **Additional Library Directories** path in your project to include the path to the original library when you link.
500
500
501
501
### To add the DLL import library to your project
502
502
@@ -508,7 +508,7 @@ To fix this issue, you could copy the library file directly into your client app
508
508
509
509
:::image type="content" source="media/mathclient-additional-dependencies-property.png" alt-text="Screenshot of the Property Pages dialog box under Input that shows the Edit command in the Additional Dependencies property dropdown.":::
510
510
511
-
1. In the **Additional Dependencies** dialog, add *MathLibrary.lib* to the list in the top edit control.
511
+
1. In the **Additional Dependencies** dialog, add *`MathLibrary.lib`* to the list in the top edit control.
512
512
513
513
:::image type="content" source="media/mathclient-additional-dependencies.png" alt-text="Screenshot of the Additional Dependencies dialog box showing the MathLibrary.lib file.":::
514
514
@@ -518,7 +518,7 @@ To fix this issue, you could copy the library file directly into your client app
518
518
519
519
:::image type="content" source="media/mathclient-additional-library-directories-property.png" alt-text="Screenshot of the Property Pages dialog box under General that shows the Edit command in the Additional Library Directories property dropdown.":::
520
520
521
-
1. Double-click in the top pane of the **Additional Library Directories** dialog box to enable an edit control. In the edit control, specify the path to the location of the *MathLibrary.lib* file. By default, it's in a folder called *Debug* directly under the DLL solution folder. If you create a release build, the file is placed in a folder called *Release*. You can use the `$(IntDir)` macro so that the linker can find your DLL, no matter which kind of build you create. If you followed the directions to put your client project in a separate solution from the DLL project, the relative path should look like this:
521
+
1. Double-click in the top pane of the **Additional Library Directories** dialog box to enable an edit control. In the edit control, specify the path to the location of the *`MathLibrary.lib`* file. By default, it's in a folder called *Debug* directly under the DLL solution folder. If you create a release build, the file is placed in a folder called *Release*. You can use the `$(IntDir)` macro so that the linker can find your DLL, no matter which kind of build you create. If you followed the directions to put your client project in a separate solution from the DLL project, the relative path should look like this:
Copy file name to clipboardExpand all lines: docs/windows/walkthrough-creating-windows-desktop-applications-cpp.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ To see the steps for your preferred version of Visual Studio, use the **Version*
53
53
The animation shows right-clicking on the project name in Solution Explorer, choosing Add in the menu that appears, and then choosing New Item.
54
54
:::image-end:::
55
55
56
-
1. In the **Add New Item** dialog box, select **C++ File (.cpp)**. In the **Name** box, type a name for the file, for example, *HelloWindowsDesktop.cpp*. Choose **Add**.
56
+
1. In the **Add New Item** dialog box, select **C++ File (.cpp)**. In the **Name** box, type a name for the file, for example, *`HelloWindowsDesktop.cpp`*. Choose **Add**.
57
57
58
58
:::image type="content" source="../build/media/desktop-app-add-cpp-file-153.png" alt-text="Screenshot of the Add New Item dialog box in Visual Studio 2019. The C plus plus File (.cpp) option is selected. The name field is set to Hello Windows Desktop.cpp.":::
59
59
@@ -81,7 +81,7 @@ Your project is now created and your source file is opened in the editor.
81
81
The animation shows right-clicking on the project name in Solution Explorer, choosing Add in the menu that appeared, and then choosing New Item.
82
82
:::image-end:::
83
83
84
-
1. In the **Add New Item** dialog box, select **C++ File (.cpp)**. In the **Name** box, type a name for the file, for example, *HelloWindowsDesktop.cpp*. Choose **Add**.
84
+
1. In the **Add New Item** dialog box, select **C++ File (.cpp)**. In the **Name** box, type a name for the file, for example, *`HelloWindowsDesktop.cpp`*. Choose **Add**.
85
85
86
86
:::image type="content" source="../build/media/desktop-app-add-cpp-file-153.png" alt-text="Screenshot of the Add New Item dialog box in Visual Studio 2017. Visual C plus plus is selected on the left and the C plus plus File option is highlighted.":::
87
87
@@ -113,7 +113,7 @@ Your project is now created and your source file is opened in the editor.
113
113
The animation shows right-clicking on the project name in Solution Explorer, choosing Add in the menu that appears, and then choosing New Item.
114
114
:::image-end:::
115
115
116
-
1. In the **Add New Item** dialog box, select **C++ File (.cpp)**. In the **Name** box, type a name for the file, for example, *HelloWindowsDesktop.cpp*. Choose **Add**.
116
+
1. In the **Add New Item** dialog box, select **C++ File (.cpp)**. In the **Name** box, type a name for the file, for example, *`HelloWindowsDesktop.cpp`*. Choose **Add**.
117
117
118
118
:::image type="content" source="../build/media/desktop-app-add-cpp-file-150.png" alt-text="Screenshot of the Add New Item dialog box in Visual Studio 2015 with Visual C plus plus selected and the C plus plus File option highlighted.":::
119
119
@@ -435,7 +435,7 @@ As promised, the complete code for the working application follows.
435
435
436
436
### To build this example
437
437
438
-
1. Delete all the code in *HelloWindowsDesktop.cpp* in the editor. Copy this example code and paste it into *HelloWindowsDesktop.cpp*:
438
+
1. Delete all the code in *`HelloWindowsDesktop.cpp`* in the editor. Copy this example code and paste it into *`HelloWindowsDesktop.cpp`*:
0 commit comments