I could only figure out that __declspec(dllexport) has something to do with export or import in visual studio. But, I do not have any idea about why and how this import and export is done. I would really appreciate if someone over here can explain to me or guide me to relevant resources.
Second thing: If I use these functions __declspec() etc, then my code would not be compilable on other compiler. If yes, what to do about that?
It's not a function, it's an extended syntax for the purpose of generating and linking DLLs.
Why generate DLLs? IIRC, the main reasons were to save memory. A shared library only needs to be loaded once to memory, even if more than one program is using it. This also saves disk space, as the code contained in the library only needs to appear once.
How DLLs are generated? Well, basically, instead of generating code into an executable, it's generated into a file that's not runnable by itself. It's sort of like a module that a program can load and use the functions it provides.
I can't seem to find any info on the second subject.