Tools, FAQ, Tutorials:
"link" - Link Object Files (*.obj)
How to use "link" command tool to link objet files?
✍: FYIcenter.com
If you have object files previously compiled by your or others, you can follow this tutorial to link them into executable files:
1. Create a simple C++ program, Hello.cpp, with a text editor:
#include <iostream> using namespace std; void main() { cout << "Hello, world, from Visual C++!" << endl; }
2. Run "All Programs > Visual Studio 2017 > Visual Studio Tools > Developer Command Prompt for VS 2017". You see the Visual Studio Command Prompt window.
3. Compile the source file Hello.cpp with "cl -c" to generate the object file only. You see Hello.obj generated:
C:\fyicenter> C:\fyicenter>cl /c /EHsc Hello.cpp Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25019 for x86 Copyright (C) Microsoft Corporation. All rights reserved. Hello.cpp C:\fyicenter>dir Hello.* 10:23 PM 122 Hello.cpp 10:33 AM 95,055 Hello.obj
4. Link the object file Hello.obj with "link" to generate the executable file. You see Hello.exe generated:
C:\fyicenter>link Hello.obj Microsoft (R) Incremental Linker Version 14.10.25019.0 Copyright (C) Microsoft Corporation. All rights reserved. C:\fyicenter>dir Hello.* 10:23 PM 122 Hello.cpp 10:35 AM 186,880 Hello.exe 10:33 AM 95,055 Hello.obj
4. Run the executable file Hello.exe:
C:\fyicenter>Hello.exe Hello, world, from Visual C++!
⇒ "MyLib.lib" - C++ Class and Static Library
⇐ "cl" - Compile and Link C++ Program
2017-08-21, 4265🔥, 0💬
Popular Posts:
How to convert a JSON text string to an XML document with PHP language? Currently, there is no built...
How to install "The Windows SDK version 8.1"? I need to build my Visual Studio C++ applications. If ...
How to use "xml-to-json" Azure API Policy Statement? The "xml-to-json" Policy Statement allows you t...
Where to find tutorials on EPUB file format? I want to know how to create EPUB books. Here is a larg...
Can Two Forms Be Nested? Can two forms be nested? The answer is no and yes: No. You can not nest two...