Process of binding to libraries (DLL's) during the C ++ source compilation process

1

During the compilation process, I think, there is some kind of link between my code and the library I'm using code for. How does my application be able to call the code of a DLL? That is, what happens during the build that promotes this link?

All I know is that I use:

#include<library>
using namesmpace nms;
    
asked by anonymous 24.03.2017 / 20:22

2 answers

1

The process has nothing to do with #include , even less with namespace .

This has to do with linking of the code. When it will use some DLL the executable is generated in a form that is indicated that the exact code will be taken from the DLL at the moment of execution and some information is put to make the call dynamic call. When calling the executable it will look for the DLL and load as necessary making an adaptation of the temporary address that had been placed in the executable to the actual address of the code present in the DLL.

The only relationship with #include is that the build needs to know the function signatures that will be called in the DLL. This is only information for the compiler, the DLL code will not be placed next to your code. Even if you have any errors in the header you will have problems during execution. The .h must have information synchronized with the code that is in the DLL.

    
27.03.2017 / 00:29
0
What happens is that when you use #include , the Operating System macro looks for the .h file or library inside your computer, and as soon as you compile it, it inserts the library code dynamically into your file.c or .cpp, so you can use the methods of this library without even knowing your implementation

    
24.03.2017 / 20:42