Process of connection to libraries (DLL’s) during the C++ source compilation process

Asked

Viewed 82 times

1

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

All I know is I use:

#include<library>
using namesmpace nms;

2 answers

1


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

This has to do with linkage of the code. When going to use some DLL the executable is generated in a form that is indicated that the exact code will be picked from the DLL at the time of execution and some information is placed to make the call dynamic link. When calling the executable it will search the DLL and load what is necessary by making an adaptation of the provisional address that had been placed in the executable to the actual address of the code present in the DLL.

The only relationship with the #include is that the compilation needs to know the signatures of functions which 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 an error in the header you will have problems while running. The .h has to have information synchronized with the code that is in the DLL.

  • Okay. Okay. But, here’s the thing: how is this linkage process done? So the executable "reference" that DLL? What *.lib files have to do with it?

  • @Paul essentially doesn’t need to do anything in most cases. The DLL needs to be available and the header need to be all ok. If you have a more concrete question ask in a new question.

  • I get it. Thank you.

0

Basically, what happens is that when you use one #include,the macro of the Operating System,looks for the file . h or library inside your computer,and as soon as you compile,it inserts the library code dynamically into your file. c or . cpp, so you can use the methods of this library without even knowing its implementation

  • 1

    This is very confusing, probably wrong.

  • was bad guy, I don’t have much experience in dynamic links dll’s libraries, but what happens to any library you include in your code, any . h, that’s basically it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.