31 Replies - 4000 Views - Last Post: 22 December 2009 - 11:58 AM
#1
Libraries vs. Header files?
Posted 21 December 2009 - 07:12 PM
Replies To: Libraries vs. Header files?
#2
Re: Libraries vs. Header files?
Posted 21 December 2009 - 07:25 PM
#3
Re: Libraries vs. Header files?
Posted 21 December 2009 - 07:27 PM
Give us some idea of where you have already been so we don't just tell you the same stuff that didn't make sense the first time.
#4
Re: Libraries vs. Header files?
Posted 21 December 2009 - 07:30 PM
#5
Re: Libraries vs. Header files?
Posted 21 December 2009 - 07:31 PM
#6
Re: Libraries vs. Header files?
Posted 21 December 2009 - 07:35 PM
@no2pencil
I understand that they aren't supposed to be linked. I meant between the 2 types of libraries and header files
#7
Re: Libraries vs. Header files?
Posted 21 December 2009 - 07:41 PM
Sn0wm4n, on 21 Dec, 2009 - 08:35 PM, said:
Say you wrote a bitchin' search algorithm, but it's huge in file size & in memory usage. You could compile it as a dll & then each program that runs it will share it's memory space. It won't exist in your executable binary, but will be required to have with it when it runs. So if you move it to another machine, it must exist there. Now, say you write a follow up project that uses this same code. You simply load the dll, & execute the function. However, if you put that code into a header file, & you have someone download product A, they are not going to recompile it. So therefore executable binary for project b must also be compiled with the bitchin' search algorithm directly in the binary executable.
Therefor, the dll is reusing code at execution time. The header file is reusing the code at compile time.
#8
Re: Libraries vs. Header files?
Posted 21 December 2009 - 07:44 PM
Sn0wm4n, on 21 Dec, 2009 - 06:35 PM, said:
All C/C++ code needs to be compiled before it will work.
C/C++ are not a script languages that can be interpreted direct from the code as written.
C/C++ code must be compiled before the code will do anything on a computer.
#9
Re: Libraries vs. Header files?
Posted 21 December 2009 - 07:51 PM
#10
Re: Libraries vs. Header files?
Posted 21 December 2009 - 07:57 PM
#11
Re: Libraries vs. Header files?
Posted 21 December 2009 - 08:02 PM
#12
Re: Libraries vs. Header files?
Posted 21 December 2009 - 08:03 PM
#13
Re: Libraries vs. Header files?
Posted 21 December 2009 - 08:05 PM
Sn0wm4n, on 21 Dec, 2009 - 08:51 PM, said:
Like No2Pencil said, you could compile a whole program together, but to make that module reusable between many different programs that all use that module, one would make it a DLL, so that it can be CALLED from the appropriate executable while still being available for others. Let's use SDL 2D game library as an example. Instead of compiling THE ENTIRE library into a single executable, you have it as separate DLLs which are used in that program. This also makes them great for when people update the executable; the end user does not have to recompile it, as it is already there set up as a DLL.
This post has been edited by Dogstopper: 21 December 2009 - 08:10 PM
#14
Re: Libraries vs. Header files?
Posted 21 December 2009 - 08:09 PM
Sn0wm4n, on 21 Dec, 2009 - 09:02 PM, said:
As you learn more about programming & software development, you will.
I guess, you can think about it like this. When is the last time that you actually opened up the header file & looked at the source code for printf (or cout)?? You know it's parameters, & you know what output to expect, so you are able to call it, pass it values, & expect a return code from it without reading into every detail of it's code. The DLL will work in this way (as to a developers situation).
#15
Re: Libraries vs. Header files?
Posted 21 December 2009 - 08:14 PM
Care in use of terms is important.
Nearly the same word can mean the exact opposite in IT so one must be careful to use exactly the term you mean.
1 - Read what No2Pencil has already said. Words of wisdom all.
2 - Have a read of these:
http://msdn.microsof...b00(VS.71).aspx
http://www.cygnus-so...ledheaders.html
http://en.wikipedia....compiled_header
As just one example:
If you have a Windows machine you can access the pre-compiled library Windows.h simply by including it in your code.
- Do you think Microsoft wants that sitting on your machine in code rather than compiled binary? You would see into their APIs in a way they don't want you to.
- You don't want all that code cluttering up your hard drive when all you need is the binary.
- If it is open code you (or someone else) might be tempted to fiddle. Suddenly all the work done by M$ to write and test that code is worth zero if any first year comp sci student can make "improvements" and thereby total their machine and spend hours on the phone to help asking why it broke.
- Do you really want to sit for extra seconds, maybe minutes, while huge libraries compile every time you want to knock up a "Hello World" (if you think you do I can assure you that you do not).
|
|

New Topic/Question
Reply




MultiQuote









|