Static Libraries & .DLLs
Hi,
I want to create a library in VC++ 6.0. Now I know this is a simple procedure for creating a single static library or a single .DLL, but if I want to have two versions of my library - one of which is a static lib, and the other a .DLL what special considerations do I need to give my code?
Any help is greatly appreciated.
Jx
As far as my understanding is,
All you need to do is specify whatever type of project you want, a DLL or a Static Lib when you start up VC++. Just make sure that when you decide to create the DLL, that you have an exported function list, otherwise the dll is pretty much useless.
Kevin =)
All you need to do is specify whatever type of project you want, a DLL or a Static Lib when you start up VC++. Just make sure that when you decide to create the DLL, that you have an exported function list, otherwise the dll is pretty much useless.
Kevin =)
-----------------------------kevin@mayday-anime.comhttp://www.mayday-anime.com
Yeah, I understand that bit.... as I said, that is the easy bit to just pick whether you want a static lib or a .DLL, but what I want to know is, if I want to compile one version of my lib to a static lib and one version to a dll, is there any pitfalls or anything I need to know or can I just do it.
Whenever you compile a dll, you need to have a .def file that holds all the exported function prototypes that you want available. If you just take the code as is and compile it once as a lib and another time as a dll, the dll will not compile without those considerations.
Maybe I am just repating myself, and you already understand this. But that is the only difference I know of when compiling a lib vs a dll.
Kevin =)
Maybe I am just repating myself, and you already understand this. But that is the only difference I know of when compiling a lib vs a dll.
Kevin =)
-----------------------------kevin@mayday-anime.comhttp://www.mayday-anime.com
Hey, you can ask me! I''ve just recently been having major headaches working with DLL''s myself.
TECHNICALLY... you don''t need a .def file in a dll... you can prefix all of your functions with "__dllspec(export)" (or som''n close to that that can be found fairly easily in MSDN), but whenever you recompile the DLL you run the risk of the functions being mapped to different calling addresses, which means any app that uses that DLL has to be rebuilt or it could malfunction.
A .def looks something like this:
Now will someone please explain exactly what a static-link library is?
Hint: set up your project to export 2 dll''s, one for "Debug" and one for "Release" using different names for both the .dll and the .lib, then set up your apps that call it to use the respective lib in their Debug/Release settings... and when you run your app in Debug, you can debug the DLL functions too (you''ll get the CPP code just like with stuff internal to your app).
--Tr][aD--
TECHNICALLY... you don''t need a .def file in a dll... you can prefix all of your functions with "__dllspec(export)" (or som''n close to that that can be found fairly easily in MSDN), but whenever you recompile the DLL you run the risk of the functions being mapped to different calling addresses, which means any app that uses that DLL has to be rebuilt or it could malfunction.
A .def looks something like this:
DESCRIPTION "My Library" ; this is a descriptionEXPORTS ; this is a list of things to export MyFunction @1 ; "1" is the ''address'' ; of the function. This ; will remain constant ; when the project changes;these comments are really stupid :^)
Now will someone please explain exactly what a static-link library is?
Hint: set up your project to export 2 dll''s, one for "Debug" and one for "Release" using different names for both the .dll and the .lib, then set up your apps that call it to use the respective lib in their Debug/Release settings... and when you run your app in Debug, you can debug the DLL functions too (you''ll get the CPP code just like with stuff internal to your app).
--Tr][aD--
--Tr][aD--
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement