Libs/dll on the device?
| Wed, 2007-04-04 07:31 | |
|
|
Hi,
Can someone please tell me what r the advantages/disadvantages of using a dll over a static lib and vice versa? And when to use a dll and when to use a lib..and what r the implications of using each of them on the device..are there any performance/speed overheads on either of them..? Cheers mayank |






Forum posts: 131
If you have applications which share a good chunk of code, it makes sense to use a DLL.
Not sure about DLL overhead, there should not be any apart from loading the library when it is requested the first time. Someone, correct me if I'm wrong.
Forum posts: 148
cheers
mayank
Forum posts: 695
Forum posts: 174
http://ptrmobile.blogspot.com/
Forum posts: 721
But the second app will not need to load the DLL again as it's already been loaded into RAM. As opposed to static LIBs.
But to also answer Mayankkedia's question: you don't need to make a separate DLL or LIB just for abstraction's sake. You can write mixins, isolate functionality in separate src/inc directories so that, when needed, you can easily put them in another file.
Tote
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/
Forum posts: 131
Forum posts: 721
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/
Forum posts: 1134
If you need to rebuild source file, it is because it has binary dependencies on some other part.
You don't solve this problem by splitting it in separate dlls.
You solve it by getting rid of the binary dependency
And you can do that with just proper moduling in different source files.
It might be easier to keep track of though if you keep it in separate dlls, because it will kick you in the nuts if you mess it up, but on the other hand it might be trickier to resolve dependency problems when they arrive, and they might be there without you realizing it, because the build environment doesnt warn you properly..
I dont see the point to split your program into several binaries just for abstractions sake.
Dlls is for shared code, all other code could just as well be statically linked.
Actually, you often gain a bit memory from useing a static linked lib, if you have a big lib with lots of functions, of wich you only use a few.
And, what do you gain by abstracting it in a dll as opposed to a static lib?
just my 2 cents
Forum posts: 721
Dlls is for shared code, all other code could just as well be statically linked.
Okay, just for abstraction's sake there might not be big benefits unless it's a big project and re-building it really takes time. In the latter case, you can split up your component into several DLLs (or LIBs, depending on how many clients you anticipate for the DLLs/LIBs) and a main executable. If you insist on a fixed API (and preferably binary compatibility) in your DLLs, then building time might be only a small fraction of the original period it took to build the whole system.
Tote
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/
Forum posts: 1134
Dlls is for shared code, all other code could just as well be statically linked.
Okay, just for abstraction's sake there might not be big benefits unless it's a big project and re-building it really takes time. In the latter case, you can split up your component into several DLLs (or LIBs, depending on how many clients you anticipate for the DLLs/LIBs) and a main executable. If you insist on a fixed API (and preferably binary compatibility) in your DLLs, then building time might be only a small fraction of the original period it took to build the whole system.
Tote
Yes. As I said. Shared code in dlls.
Everything else statically linked.
Clarification:
If you have a big pile of code that doesn't change much (compared to the rest of your system), it could be a good idea to put it in a (statically linked) lib.
But there really isn't much point in a dll unless you share the code.
Or want to be able to upgrade the dll independently from the rest of the system.
If you don't, putting it in a dll will just give you more work for no gain.
Also, it will take more memory to have it in a dll then in a static lib if it is only used by one binary.
Forum posts: 721
Tote
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/
Forum posts: 131
Forum posts: 1134
Well, if you don't have any dependencies between the different .o files, you don't have to rebuild them either.
Just rebuild the .o-files with the dependencies.
This make takes care of for you, as long as your dependencies are set up right.
Now its true the symbian build environment might force you to rebuild things you shouldn't need to sometimes, usually because of resources...
But its still not a reason to put it in a DLL, freeze the API, and allocate a UID to it.
You get that same modularity without the work overhead of messing with freeze files (not that its that much problem, but frustrating when it messes with you) by putting in it a static lib.
Also, the linker can to a better job if its in a lib instead...
I think you should try put your code in a static lib and link it in, and compare the binary size of the result to the binary size of the two dlls... I think you might be supprised
This all still if the code is not shared... If it is, then ofcourse, dlls are the way to go.
Forum posts: 1134
You also need to maintain binary compatibility (that is, the size of the object too), not just the API entry function order (freeze .def file), if you want to avoid having to rebuild "everything"
This can be quite a hassle in early development.
It means you can not add any new members variables to the exported class, and nor can you add any virtual functions too it, or you will open a can of User:42. (until you makes sure you clean up .lib files (which the build system have a a habit of leaving, even if you do a reallyclean), and relink the user of the DLL)
This is not a problem with static libs.
Forum posts: 721
It's mostly true. However, especially in early development there are methods to minimize the hassle. Typically, you publish the API of your DLL in a stub component that you're going to develop further while others are writing their own code relying on your published DLL. Of course, re-building will most probably be necessary but at least you can try to keep the number of it at minimum.
Also, you're recommended to write your API using the Bridge design pattern, which gives you the freedom of modifying the API (data members, non-published helper methods in your class, etc.) freely.
But, again, in general you're right. DLLs, especially when used by others, binds you to keep every kind of compatibility you can.
Tote
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/