1/50
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What is compilation?
Compilation converts source code into object code containing machine-language instructions. Memorize: Converts source code into object code.
What is linking?
Linking combines object files into a single executable and resolves external function references and libraries. Memorize: Linking builds the final executable.
What is static linking?
Static linking embeds library code into the executable at compile/link time
Why is static linking self-contained?
Because all required library code is included inside the final .exe at link time. Memorize: Everything is bundled into the EXE.
Role of header files in static linking
Header files tell the compiler about available functions
Role of function prototypes in static linking
Prototypes allow the compiler to verify function calls use the correct parameters and return types. Memorize: Prototypes validate function usage.
What is dynamic linking?
Dynamic linking loads the library at runtime instead of compile time and requires external DLLs to be present. Memorize: DLL loads at runtime.
When does dynamic linking occur?
During program execution
Static vs Dynamic: Binary Size
Static: Larger executable because library code is embedded. Dynamic: Smaller executable since library stays external. Memorize: Static big
Static vs Dynamic: Portability
Static: Highly portable
Static vs Dynamic: Memory Usage
Static: Each process loads its own copy of the library. Dynamic: DLL code can be shared in memory across processes. Memorize: Static = separate copies
Static vs Dynamic: Updates & Security
Static: Must rebuild full .exe to update libraries. Dynamic: Update DLL once and all programs use the new version. Memorize: Static needs rebuild
Static vs Dynamic: Performance
Static: Slightly faster (no dynamic loading). Dynamic: Minor overhead to load/resolve functions. Memorize: Static faster startup.
Static vs Dynamic: Reverse Engineering
Static: Harder to isolate library code inside exe. Dynamic: Exported functions in DLL easier to inspect. Memorize: DLL exports are visible.
Static vs Dynamic: Versioning
Static: No version conflicts. Dynamic: Risk of “DLL Hell” (wrong DLL version). Memorize: Dynamic may cause version issues.
Events to handle in dynamic linking
"Must handle: missing DLL, incorrect version, LoadLibrary failure, GetProcAddress failure, runtime dependency issues. Memorize: Must handle DLL load + version failures."Also consider: thread safety, symbol resolution errors, and security vulnerabilities.
How to statically link
"Uncommon library: #pragma comment(lib, ""<libname>""). Common library: just #include <library>. Memorize: Use #pragma or #include." Linking an external library during the compile time by specifying it directly in the code using compiler directives. This ensures that all necessary code from the library is included in the resulting executable.
What does LoadLibrary do?
Loads a DLL into memory at runtime so functions can be accessed. Memorize: Loads DLL at runtime.
What does GetProcAddress do?
Retrieves the address of an exported function from a loaded DLL so it can be called. Memorize: Gets function address from DLL.
When is DLLMain called?
DLLMain runs when the DLL loads, unloads, and when threads attach/detach. Memorize: Runs on load/unload and thread events.It is invoked by the system during the initialization and termination of the DLL lifecycle.
Exported vs non-exported functions
Exported functions can be called outside the DLL; non-exported functions remain internal and private. Memorize: Exported = public, non-exported = private.
How to export a function
"Use: extern ""C"" __declspec(dllexport) before the function definition. Memorize: Use __declspec(dllexport) to export."
How to call a function dynamically
"Load DLL, create function pointer, assign with GetProcAddress, then call through pointer. Memorize: Load DLL → GetProcAddress → call via pointer."