source vs lib vs dll1 vs dll2

Started by
5 comments, last by wah_on_2 20 years, 8 months ago
Hi, I have question again. I am writing utilities classes and I am confusing the output format of its. I know i have 4 choices. 1: I just wrting the classes and if the other programs use the classes, just include the .cpp and .h files. 2: I write a static library and if the other program use the classes, just include the header file and link with the .lib 3: I create a dll file and export the function. If the other program use the classes, just use LoadLibrary() and GetProcAddres() to get the function pointer. 4: I create a dll file and if the other program use the classes, just include the header file and link with the lib. And run with the dll file. However, i don''t know the benfits and the drawback of each one. (I just know i must re-compile the other programs when the utilities classes have small change(e.g. change variable name in a function) in the choice4 but choice3 need not. Which one is better? Can explain its to me? Thx
Advertisement
I''m currently using choice 2, for my personal code.

Choice 1 is very easy, but can get ugly, since you end up with about 30,000,000 .cpp and .h files cluttering up your project.

Choice 2 is also fairly easy, gets rid of the excess .cpp and .h files, but if you make a change to the library, you do need to recompile, still.

Choice 3 isn''t that easy, but does allow you to make changes without a full recompile. This is probably the best choice if you''re going to release your library for others to use, since they can just plug in the new .dll.

Choice 4 sounds like a hybrid: the headache of exporting a dll, with the bother of having to recompile whenever you make even a minor change.

So, if you''re doing small, personal stuff, I''d stick with 1 or 2. If you''re intending for others to use it, look at 3.

Of course, this is all my personal opinion. Others may look at it differently.

-Odd the Hermit
I like number 4, the benefits are:
* You won''t have to recompile the program to update the libraries.
* Easy access to the functions
And the disadvantages:
* 100000 dlls(you could berge everything in one, actually, the best way to go is to statically link everything in the final version, if you are not going to change anything later on.)
* A little slower than direct access through static linking or just compiling it in. It''s not something you''ll notice unless you are writing a graphics engine or something like that though.
I have something against distributing an application with many dlls. Feels kind of unrobust many times I don''t really know why I feel that way. But I much rather just release one big exe file

Just my thoughts!

My game: Swift blocks
DISCLAIMER: If any of the above statements are incorrect, feel free to deliver me a good hard slap!My games: DracMan | Swift blocks
That is funny because I am exactly the opposite. I like having tons and tons of files. If I packed everything (graphics and all) into an exe I would feel stupid redistributing it. Like I have not done any work because there is only one file. Anyway, I use #3 in my current project.
-Greg

Reverie Entertainment
i never used dll''s , and i was wondering what are the advantages to using them ? i know you can do something like openglrenderer.dll & direct3drenderer.dll and at runtime choose only one , but looking at alot of software i see they are using dll''s not just like that , what are the benefits ?
also how is it when you are debugging your program and the code calls a dll ? what if the bug is in the dll ? please explain with details.
Um...Do you think that does this question related to the effect come up with the maintain issue?

In fact, i perfer choice3 in my mind, it is the lowest drawback produce, at least, i do not need re-compile the applications. however, it is difficult to program(The application need to do many the unnecssary things. e.g. GetProcAddress)
It is something like that:
bool isOK = true;
choice1: if(isOK)
choice2: if(isOK == true)
which one will you choose? I perfer choice2 for more clear. However, the program will become unsimple.

On the other hand, do you think that the modify time is low on the utility class? If it is correct, that mean we can ignore the change in the utility class and we should use choice4 for archieve the easy to use issue each time? Also, i found company perfer choice choice4 in their products, e.g. DirectX

What do you think?

This topic is closed to new replies.

Advertisement