It really depends on what you want to use the DLL for.
OK, here's a short overview of library types and usage:
1) STATICLY LINKED LIBRARY
This type of file is compiled directly into the program code. You use this type just to separate parts of a project. It really is no different from including the .cpp files directly. You can use the code inside a static lib by including the headers into your project, and then just calling the functions/classes whatever.
Advantages: You don't have to build a list of exports with this approach, as the header files take over that function.
2) DYNAMICLY LINKED LIBRARY
This type of file is compiled separately from the program code. The advantages of this type are that when bugs occur in the DLL, all you have to do is to overwrite the DLL with a new version, and the program will still work correctly with it. Writing a DLL in this way generates a .lib file, which you link staticly to your EXE. This .lib file contains the function names, a list of exports, etc. that make the DLL work. You can also export classes from the DLL.
Advantages: Splitting up the code into multiple files makes it easier to fix bugs.
3) DYNAMICLY LINKED DYNAMICLY LOADED LIBRARY
This type of file is very special. You must write code to load it into your program manually (in Windows, you use LoadLibrary()/FreeLibrary()). This type of DLL cannot export classes or functions, because you must hard-code all the linking in yourself.
Well, this is how plugins are designed -- they sport all of the same function names, but have different code in them. The program typically uses them by loading the DLLs in one-by-one, and then calling some standard functions to initialize them. The standard functions are whatever you define.
Advanages: You don't have to know before-hand what DLLs you will be using. (P.S. If you want to use this type, I've got a dandy example for wrapping each DLL in a class.)
Actually, you are not required to put any code in a DLL. Just put in whatever code you want. If you want to know what compiler standard keyword there is, I don't think there is any. (I know __declspec(dllexport) in VC, but that's MS-specific.) You'll most likely have to write a .def file for the DLL, which should be well-documented by your compiler's docs.
Good Luck!
-
null_pointerSabre MultimediaEdited by - null_pointer on June 9, 2000 8:42:25 AM