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/reference/dot-lib-files-as-linker-input.md
+12-15Lines changed: 12 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -45,39 +45,36 @@ translation.priority.ht:
45
45
# .Lib Files as Linker Input
46
46
LINK accepts COFF standard libraries and COFF import libraries, both of which usually have the extension .lib. Standard libraries contain objects and are created by the LIB tool. Import libraries contain information about exports in other programs and are created either by LINK when it builds a program that contains exports or by the LIB tool. For information on using LIB to create standard or import libraries, see [LIB Reference](../../build/reference/lib-reference.md). For details on using LINK to create an import library, see the [/DLL](../../build/reference/dll-build-a-dll.md) option.
47
47
48
-
A library is specified to LINK as either a file name argument or a default library. LINK resolves external references by searching first in libraries specified on the command line, then in default libraries specified with the [/DEFAULTLIB](../../build/reference/defaultlib-specify-default-library.md) option, and then in default libraries named in .obj files. If a path is specified with the library name, LINK looks for the library in that directory. If no path is specified, LINK looks first in the directory that LINK is running from, and then in any directories specified in the LIB environment variable.
48
+
A library is specified to LINK as either a file name argument or a default library. LINK resolves external references by searching first in libraries specified on the command line, then in default libraries specified with the [/DEFAULTLIB](../../build/reference/defaultlib-specify-default-library.md) option, and then in default libraries named in .obj files. If a path is specified with the library name, LINK looks for the library in that directory. If no path is specified, LINK looks first in the directory that LINK is running from, and then in any directories specified in the LIB environment variable.
49
49
50
-
###To add .lib files as linker input in the development environment
50
+
## To add .lib files as linker input in the development environment
51
51
52
52
1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md).
53
53
54
-
2.Click the **Linker** folder.
54
+
2.Choose the **Input** property page in the **Linker** folder.
55
55
56
-
3.Click the **Input** property page.
56
+
3.Modify the **Additional Dependencies** property to add the .lib files.
57
57
58
-
4. Modify the **Additional Dependencies** property.
58
+
## To programmatically add .lib files as linker input
59
59
60
-
### To programmatically add .lib files as linker input
61
-
62
-
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool.AdditionalDependencies>.
60
+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool.AdditionalDependencies%2A>.
63
61
64
62
## Example
65
-
The following sample shows how to build and use a .lib file:
63
+
The following sample shows how to build and use a .lib file. First, build a .lib file:
66
64
67
-
```
65
+
```cpp
68
66
// lib_link_input_1.cpp
69
-
// compile with: /LD
67
+
// compile by using: cl /LD lib_link_input_1.cpp
70
68
__declspec(dllexport) int Test() {
71
69
return 213;
72
70
}
73
71
```
74
72
75
-
## Example
76
-
And then:
73
+
And then, compile this sample by using the .lib file you just created:
77
74
78
-
```
75
+
```cpp
79
76
// lib_link_input_2.cpp
80
-
// compile with: /EHsc lib_link_input_1.lib
77
+
// compile by using: cl /EHsc lib_link_input_1.lib lib_link_input_2.cpp
0 commit comments