Skip to content

Commit 87e144c

Browse files
committed
Create IncludeDLLs.md
Brief Description of the idea of DLL and Linking, and some given examples talking about order of operations when linking and Briefly mentioning how each area works, this is half way done currently! + Requires ProofReading + Requires additional context etc.
1 parent 55764c2 commit 87e144c

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
layout: default
3+
title: Include DLLs
4+
nav_order: 2
5+
parent: Visual Studio
6+
grand_parent: IDE
7+
has_children: false
8+
---
9+
10+
{{ page.title }}
11+
======================
12+
13+
### Introduction:
14+
15+
16+
#### What is a DLL?
17+
18+
- Dynamic Link Library, alternatively referred to as a (DLL), is an amalgamation of code and its associated data intended for widespread use across diverse applications, employing shared code for streamlined functionality. DLLs are specifically crafted to optimize software performance, enhance efficiency, and promote the systematic reuse of code within application development. As linking is established during runtime or while the program is in active execution.
19+
20+
21+
#### What can be considered as linking?
22+
23+
- Linking in programming refers to the process of combining pieces of code or files to create a single executable program. There are two different types of linking in programming that are typically used see the following:
24+
25+
- [Compile-Time Linking](https://learn.microsoft.com/en-us/cpp/cppcx/static-libraries-c-cx?view=msvc-170) (Static Linking)
26+
27+
- Read about Static Linking < here >.
28+
29+
- [Runtime Linking](https://learn.microsoft.com/en-us/windows/win32/dlls/run-time-dynamic-linking) (Dynamic Linking):
30+
31+
Functionality:
32+
33+
- The linking process happens dynamically, allowing the program to access functions and resources from shared libraries on-the-fly.
34+
35+
- During runtime linking, the executable (.exe) file is connected with external libraries when the program is being launched or when it is running.
36+
37+
Advantages:
38+
39+
- Reduced memory usage (Allows the program to share a single copy of a library in the memory, reducing the usage of memory and calls).
40+
41+
- Promotes modularity and reusability (Organizes the code-space reducing the quantity of files required).
42+
43+
- Ease of maintaining (Librares can be applied or updated without having to re-compile the program).
44+
45+
Cons:
46+
47+
- Dependency (When libraries are not present or incompatible with the executable or other dependable files, the program may fail to execute or produce a run-time error).
48+
49+
- Security (May include malicious and compromised libraries, that could be overlooked when vertifiying the integrity and authenticity of the loaded libraries).
50+
51+
- Reduced control during compile-time (Addressing error or issues caused by linking can be time consuming as it requires runtime to load them, which makes it harder to catch and fix the issues during development and testing).
52+
53+
### Execution Order for DLL Lookup:
54+
55+
In the course of the program's execution, it necessitates the specified dependencies (DLLs), which are identified and located by either the Integrated Development Environment (IDE) or the program's predetermined sequence. The pre-defined order of operations involves searching in the following locations:
56+
57+
#### System Directory:
58+
59+
The system directory, known as the system folder, location where the operating system initiates its search for the required DLL. This directory is an integral part of the operating system and contains crucial system files necessary for its functionality. If the DLL is located in this system directory and made publically accessible, the operating system promptly loads it to meet the program's requirements. The path to the system directory varies among operating systems, such as C:\Windows\System32 on Windows.
60+
61+
#### Root Directory (Current directory):
62+
63+
This root directory is typically where the main executable file (.exe) of the application resides. It is the top-level folder of the application's file structure and often represents the location where the application is installed or launched. If the required DLL is found within this root directory, it is prioritized over versions found in other locations, ensuring that the specific DLL required by the program takes precedence during execution.
64+
65+
#### Defined Locations (PATH):
66+
67+
The operating system extends its search to directories explicitly defined in the system PATH environment variable. The PATH variable contains a list of directories specified by the user or system administrator to enable convenient access to frequently used programs and libraries. These defined locations serve as a catalog of commonly utilized resources, and the operating system explores them in the specified order. If the required DLL is present in any of these PATH-defined directories, it is loaded, contributing to the seamless execution of the program.
68+
69+
[Source Documentation by Microsoft " Dynamic link library search order. "](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order)
70+
71+
72+
### Linking DLLs in Visual studio
73+
74+
Based on an (IDE) Visual Studio 2022, there are three ways of linking DLLs:
75+
76+
77+
#### System directory linking:
78+
79+
+ To Be Written.
80+
+ Must be in the system files and made globally accessible.
81+
82+
#### Root directory linking:
83+
84+
- The DLLs are in the same directory as the .vcxproj are listed the core also known as root directory.
85+
86+
File structure (Root):
87+
88+
> Example.dll
89+
>
90+
> main.cpp
91+
>
92+
> Application.sln
93+
>
94+
> Application.vcxproj
95+
>
96+
> Application.vcxproj.user
97+
>
98+
> App.Tetris.vcxproj.filters
99+
100+
- Root linking the is beneficial for small projects as the developer is not required to link anything themseleves as the IDE does it for them.
101+
102+
- The issue: directory is messy and becomes hard to manage and to re-scale due to the files cluttering the resource and collaboration ineffectivness.
103+
104+
+ !Change Root Directory.!
105+
106+
107+
#### Defined locations (PATH):
108+
109+

0 commit comments

Comments
 (0)