A I said in comments under MS Windows OS the dynamic library have some characteristics that don't pertain to static library code. Let try to explain in very plain way:
First of all a DLL is loaded independently from current executable, and directly from the OS module loading function, as a separate object which code memory is mapped in the current process memory, but retained to be mapped in a different process.
During the loading the loader creates different memory areas that can be unique for a single process or shared between processes or private to DLL internal functions.
The shared areas permits to create mutex's,semaphores and any data necessary to the kernel to arbitrate the multitasking environment and resources sharing.
On the reverse a static library is loaded only in the current process, the code segment lays together with the user program code segment, and the data segment, in same way, is added to the current executable data space.
For these reasons, and much more, you can't statically link any system library function to your executable.
A simple experiment on static and dynamic linking using the CRT libraries.
Create a main program in where you open a file:
#include <stdio.h>
extern void DllReadRoutine(FILE *);
int main(int argc, char *argv[])
{
FILE *fp = fopen("Myfile.txt", "r");
//Diagnostic omitted to keep it simple
DllReadRoutine(fp); //Pass the file pointer to the external DLL function
fclose(fp);
return 0;
}
Now create DLL (we omit DLL entry):
#include <stdio.h>
void DllReadRoutine(FILE *fp);
int main(int argc, char *argv[])
{
int c;
while ((c=fgetc(pFile)) != EOF)
{
putchar(c);
}
}
Then compile the two linking the CRT statically the first time (use /MT on MSVC) and dynamically the second (use /MD on MSVC).
In the first case the DLL function will fail because the static linking to CRT creates local open files table that is incompatible with the table local to the main executable. The result is a crash.
In the second case the internal CRT data, as the open files table, is created in a shared area where both, executable and DLL, access. In this case the code will work smoothly.