mr4th-dynamic-linking/win32_linking/DETAILS.txt

42 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

win32_main.c defines the executable win32_main.exe
it depends on load-time linking with win32_base.dll
it tries to perform run-time linking with win32_plugin.dll
win32_base.c defines the binary win32_base.dll
win32_plugin.c defines the binary win32_plugin.dll
it depends on load-time linking with win32_base.dll
The build script has to build win32_base.c first because it needs the
results of that build to setup the load-time linking in the other builds.
The win32_base.lib that is generated along with win32_base.dll is used
to resolve load-time imported symbols.
The program has a shared data structure 'int x' in the 'base' layer that is
read and modified from both the 'main' layer and 'plugin' layer.
The expected output if the plugin loads successfully is:
```
x = 0
provided by plugin: {
x = 1
x = 2
}
x = 3
```
The expected output if the plugin is not found is:
```
x = 0
x = 1
```
You should be able to relocate the plugin and use a full path to it and still
get the first result. As long as the load-time dependency win32_base.dll is
with the executable, it will load. It can be found in some other paths, but
you cannot specify the search paths manually, so keeping it with the executable
is the simplest option.