Need a refresher, the difference between static and dynamic.

This is a discussion on Need a refresher, the difference between static and dynamic. within the C++ Programming forums, part of the General Programming Boards category; I haven't been using as much C++ these days as I would like to and am getting back into installing ...

Need a refresher, the difference between static and dynamic.

I haven't been using as much C++ these days as I would like to and am getting back into installing some libraries. I was just wondering, when creating projects using the libraries, there are the static libraries that are the standard .a files and the .a filles that are postfix with dll and come complimentary with dlls. If I remember the dll enabled libraries allow the compilation of the source code and allow the program to execute functions during runtime, while the .a files compile all the functions entirely. Am I correct?

.a/.lib are static libraries. When you link them against your program, the linker pulls the code from the library and adds it to your executable.

.so/.dll are dynamic libraries. When you link them against your program, the linker marks the dependency in the header and creates indirect calls in the code. The program loader loads the required dynamic libraries and resolves the indirect calls.

Dynamic libraries can also be loaded at runtime with the appropriate functions (dlopen()/LoadLibrary()). This is not possible with static libraries.

If I wanted to create the functionality seen in something like C# where you can invoke the methods and classes from just a dll file without the .a, is it possible?

It is certainly possible to load a library at runtime. I'm a bit blurry on the details of how you achieve that, because you essentially need to have a connection to get the vtable from the DLL. I'm sure someone else can explain, or perhaps you can find the answer on the web somewhere.