Reputation: 1399
For example, let's say I have the following structure:
my_program
| main.c - defines main()
| foo.c - defined foo()
my_dll
| dll_start.c - defined dll_start()
| foo.c - defines foo()
where main() calls foo() and then dll_start().
In what order are they called? For example, is it:
?
Basically, I want to know if when you create a dynamic library, if the linker (does the linker even run?) always uses symbols inside the dll when resolving symbols inside the dll itself - for example, in this case, does the foo() inside my_dll call the my_dll::foo or the my_program::foo?
Upvotes: 0
Views: 38
Reputation: 104464
Yes, the linker runs to finalize the build of the DLL and will need a definition of foo
to build. But as long as you aren't linking the same library of code containing my_program::foo
into my_dll.dll
, the foo
picked up for linking the DLL itself will be my_dll::foo
.
The only time you can get yourself in trouble here is if you had a shared.lib
static code library that implements an independent foo
function and is linked with both with the EXE and DLL. It might be ambiguous which one the DLL picks up if it has a local implementation of foo
.
Upvotes: 1