please, could someone explain to me a few basic things about working with languages like C? Especially on Windows?
-
If I want to use some other library, what do I need from the library? Header files .h and ..?
-
What is the difference between .dll and .dll.a.? .dll and .lib? .dll and .exe? What is .def?
-
Does it matter how was the library compiled? I mean, is it possible to use, on Windows, a C++ library compiled by VC from within my C code compiled by MinGW?
-
To use another library, what is preferred way? LoadLibrary() or #include <>?
-
There are some libraries which only provide the source code or .dll – how to use such libraries? Do I have to recompile them every time I rebuild my project?
-
How do I create one big .exe? Is this called "static linking"?
-
How to include some random file into .exe? Say a program icon or start-up song?
-
How do I split my huge .c into smaller ones? Do I need to create for every part a header file which then I include in the part with WinMain() or main()?
-
If there is a library which needs another library, is it possible to combine these two into one file? Say, python26.dll needs msvcr90.dll and Microsoft.VC90.CRT.manifest
-
What happens if I don't free previously allocated memory? Is this going to be cleaned up if the program (process) dies?
Well, so many question… Thanks for every info!
Best Solution
... and, usually a
*.lib
file which you pass as an argument to your linker.This might be useful: Static libraries, dynamic libraries, DLLs, entry points, headers … how to get out of this alive?
Yes, it matters. For interop between compilers, the normal way is to use a C-style (not C++-style) API, with well-defined parameter-passing conventions (e.g.
__stdcall
), or to use 'COM' interfaces.#include
is for the compiler (e.g. so that it can compile calls to the library); andLoadLibrary
(or, using a*.lib
file) is for the run-time linker/loader (so that it can substitute the actual address of those library methods into your code): i.e. you need both.If it's only source then you can compile that source (once) into a library, and then (when you build your project) link to that library (without recompiling the library).
Yes, compile everything and pass it all to the linker.
Define that in a Windows-specific 'resource file', which is compiled by the 'resource compiler'.
Yes.
I don't understand your question/example.
Yes.