Board index » cppbuilder » Re: Static linked library in Package not allowed

Re: Static linked library in Package not allowed


2007-08-10 11:11:50 AM
cppbuilder77
Quote
A .DLL is a collection of .OBJ files...
Not true. A DLL is an EXE with a bit flipped in its header to indicate that
it is a dynamic loaded library instead of a standalone executable. It does
NOT contain object files.
. Ed
Quote
Valence wrote in message
news: XXXX@XXXXX.COM ...

I know you've seen this, I just can't resist putting it out here.

<BCB6 Help DLL review>
A .DLL is a collection of .OBJ files, or modules, that an .EXE can link to
either "statically" -- meaning that the .DLL must be present for the .EXE
to run -- or "dynamically", which means that the .DLL loads only when the
.EXE needs it to.
There is a difference between statically linking a .DLL, and "using static
linking".

Static linking means that you are linking with a library that contains all
of the necessary OBJs. This is not a DLL, but rather a static library.
Typically these have a .LIB extension.
Statically linking with a .DLL means that you are linking with an import
library that contains references to the DLL.
Dynamically loading the .DLL means that you are calling the WinAPI
function "LoadLibrary".

So the three permutations are: static linking with a .LIB, statically
linking with an import library (also a LIB) which references a .DLL, and
dynamically loading a .DLL (using "LoadLibrary" or using the delay load
feature).
<\BCB6 Help DLL Review>
 
 

Re:Re: Static linked library in Package not allowed

Valence wrote:
Quote
code: a word, letter, number, or other symbol used in a code system to mark,
represent, or identify something: The code on the label shows the date of
manufacture.
[snip]
Quote

So Import libraries do contain "code". That "code" by its presence and
content does exactly as I meant to say.
Import libraries do not contain commands.



Well, in programming the word 'code' usually means machine instructions
or higher level programming language. When advocating precise usage of
words, please do.
.a
p.s. the code in import library doesn't do anything. It's linker and OS
loader that do things.
 

Re:Re: Static linked library in Package not allowed

"Alex Bakaev [TeamB]" < XXXX@XXXXX.COM >wrote in message
.a
Quote

p.s. the code in import library doesn't do anything. It's linker and OS
loader that do things.
I thought I conceded that already, by referencing its "presence".
 

{smallsort}

Re:Re: Static linked library in Package not allowed

Valence wrote:
Quote

code: a word, letter, number, or other symbol used in a code system
to mark, represent, or identify something: The code on the label
shows the date of manufacture.
<snip>
Quote
So Import libraries do contain "code".
That's pure nonsense. We were discussing executable code, and you know
it.
--
Rudy Velthuis [TeamB] rvelthuis.de
"Forgive your enemies, but never forget their names."
-- John F. Kennedy (1917-1963)
 

Re:Re: Static linked library in Package not allowed

"Ed Mulroy [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
>A .DLL is a collection of .OBJ files...

Not true. A DLL is an EXE with a bit flipped in its header to indicate
that it is a dynamic loaded library instead of a standalone executable.
It does NOT contain object files.

. Ed

>Valence wrote in message
>news: XXXX@XXXXX.COM ...
>
>I know you've seen this, I just can't resist putting it out here.
>
><BCB6 Help DLL review>
>A .DLL is a collection of .OBJ files, or modules, that an .EXE can link
>to either "statically" -- meaning that the .DLL must be present for the
>.EXE to run -- or "dynamically", which means that the .DLL loads only
>when the .EXE needs it to.
>There is a difference between statically linking a .DLL, and "using
>static linking".
>
>Static linking means that you are linking with a library that contains
>all of the necessary OBJs. This is not a DLL, but rather a static
>library. Typically these have a .LIB extension.
>Statically linking with a .DLL means that you are linking with an import
>library that contains references to the DLL.
>Dynamically loading the .DLL means that you are calling the WinAPI
>function "LoadLibrary".
>
>So the three permutations are: static linking with a .LIB, statically
>linking with an import library (also a LIB) which references a .DLL, and
>dynamically loading a .DLL (using "LoadLibrary" or using the delay load
>feature).
><\BCB6 Help DLL Review>


<greetings>
Thanks Ed. I can always count on you for exacting and precise information. I
love all you guys, and find these exchanges extremely fun, and informative.
I remember the good ole' days, and expected that you would eventually find
this thread irresistable. It seemed right down your ally.
Where's Chris to rebut? I haven't seen you guys spar in a good while!
<\greetings>
<retoric>
I think that the BCB 6 documenter (god rest his soul) was trying to be
general enough to be "generally" understood. He wasn't communicating to the
ultra-geeks or the prudes. At least not to level of exactitude that is, of
course, necessary in this thread.
<\retoric>
 

Re:Re: Static linked library in Package not allowed

"Rudy Velthuis [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
Valence wrote:


>So Import libraries do contain "code".

That's pure nonsense. Rudy Velthuis [TeamB] rvelthuis.de
...
"Forgive your enemies..."
It is not. Sadly, it is not.
 

Re:Re: Static linked library in Package not allowed

"Ed Mulroy [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
>The reason I like the more common term "Statically linking" is soley due
>to the fact that the static import library is used to load the DLL ...

There is no such thing as a STATIC import library. It is an import
library, the EXPORTS section of a module definition file bundled into
another format.

. Ed

Thanks Ed, very good catch as usual. I will rephrase to provoke further
rebuttal. Do know that I have updated my vocabulary, with support for you
guys and google, and accept the definition of "implicit linking". With
reference to a "static" import library. I will simply say, sorry I didn't
quote it as I tried to quote everything else like this.
Quote
>Valence wrote in message
>news:46bb88c3$ XXXX@XXXXX.COM ...
>
>The reason I like the more common term "Statically linking" is soley due
>to the fact that the static import library is used to load the DLL and
>that in turn makes using the DLL "feel" like static linking to a .lib
>alone.
>
>"implicit" linking suggests linking without telling it to link, but you
>have to explicitly include the "static" import library. So hmm :-(.
If the import library, or rather the content generated in the .exe by the
linker per that library is dynamic, how so? And if not dynamic, is it
static.
But again, I forget the thread I'm in. I'd better add that I agree that an
import library is not a static library, though it might be obvious
elsewhere. Any attempt to be general here is certainly folly.
 

Re:Re: Static linked library in Package not allowed

Valence wrote:
Quote

"Alex Bakaev [TeamB]" < XXXX@XXXXX.COM >wrote in message
news:46bc09d1$ XXXX@XXXXX.COM ... .a
>
>p.s. the code in import library doesn't do anything. It's linker
>and OS loader that do things.

I thought I conceded that already, by referencing its "presence".
Huh? That doesn't make a lot of sense.
--
Rudy Velthuis [TeamB] rvelthuis.de
"Gentleman: Knows how to play the bagpipes, but doesn't."
 

Re:Re: Static linked library in Package not allowed

Valence wrote:
Quote
>>So Import libraries do contain "code".
>
>That's pure nonsense.
It is not. Sadly, it is not.
It is. You come with a definition of code no one here was meaning or
using, just to win your argument. That is plain silly. <shrug>
So to be clear: import libraries do not contain executable code. "And
thats not up for debate" (sic).
--
Rudy Velthuis [TeamB] rvelthuis.de
"If we knew what it was we were doing, it would not be called
research, would it?" -- Albert Einstein
 

Re:Re: Static linked library in Package not allowed

Rudy Velthuis [TeamB] < XXXX@XXXXX.COM >wrote:
Quote
Hendrik Schober wrote:
>Rudy Velthuis [TeamB] < XXXX@XXXXX.COM >wrote:
>>[...]
>>"Statically linking to a package" is just as wrong as "statically
>>linking to a DLL". You link a lib, not a a package.
>
>I wouldn't know about packages, but "statically linking
>to a DLL" is a widely used and rather handy term for
>"linking to a DLL's import library" and is thus not
>wrong.

And what is dynamically linking to a dynamic link library then?
Is that a rethorical question or why do you
ask something that you then answer yourself
later?
Schobi
--
XXXX@XXXXX.COM is never read
I'm HSchober at gmx dot de
"If there were some arcane way to remove the heads of every
newsgroup troll on the planet, I think it would elevate
humans to a whole new level of intelligence."
Rocky Frisco
 

Re:Re: Static linked library in Package not allowed

Hendrik Schober wrote:
Quote
>And what is dynamically linking to a dynamic link library then?

Is that a rethorical question or why do you
ask something that you then answer yourself
later?
I don't answer it. I merely showed how others call it, and I was
interested in your take.
--
Rudy Velthuis [TeamB] rvelthuis.de
"Maybe this world is another planet's Hell."
-- Aldous Huxley (1894-1963)
 

Re:Re: Static linked library in Package not allowed

Rudy Velthuis [TeamB] < XXXX@XXXXX.COM >wrote:
Quote
Hendrik Schober wrote:

>>And what is dynamically linking to a dynamic link library then?
>
>Is that a rethorical question or why do you
>ask something that you then answer yourself
>later?

I don't answer it. I merely showed how others call it, and I was
interested in your take.
I find "implicit linking" a pretty good term, though
"explicit linking" doesn't seem to fit as well to me.
But that doesn't change the fact that I keep hearing
"static/dynamic linking" referring to DLLs and that
most people know what it refers to. With even both MS
(who, after all, invented DLLs) and Borland/Codegear
using these terms, I don't see how one can call it
stupid to talk about "statically linking a DLL". (This
was, if you care to remember, where I came into this
discussion.) The term is used that way whether one
likes it or not. And there are far worse terms used
throughout our field (like RAII, which isn't about
initialization at all).
Schobi
--
XXXX@XXXXX.COM is never read
I'm HSchober at gmx dot de
"If there were some arcane way to remove the heads of every
newsgroup troll on the planet, I think it would elevate
humans to a whole new level of intelligence."
Rocky Frisco
 

Re:Re: Static linked library in Package not allowed

"Hendrik Schober" < XXXX@XXXXX.COM >wrote:
Quote
likes it or not. And there are far worse terms used
throughout our field (like RAII, which isn't about
initialization at all).
Well, initialisation *is* involved. It's the RAII object's
initialisation that is meant - you're initialising the object with the
allocated resource.
(Bjarne has been reported as saying that he apologises for that
terminology. But we look to be stuck with it.)
Alan Bellingham
--
Team Browns
ACCU Conference 2008: 2-5 April 2008 - Oxford (probably), UK
 

Re:Re: Static linked library in Package not allowed

Valence wrote:
Quote
code: a word, letter, number, or other symbol used in a code system to mark,
represent, or identify something: The code on the label shows the date of
manufacture.
Oh please. Do not bring a layman's definition of the word code into a
discussion about software development. Every profession has a vocabulary
that is unique to it. When speaking within a profession, you are
expected to understand and use that vocabulary appropriately. In the
software development community, code means machine code, not the born on
date code that you see on bottle of Budweiser.
A PE executable file consists of various segments. Some segments contain
code (ie machine code), and some contain data. The import table resides
in a data segment called idata. If you start claiming that the import
data segment contains 'code' from the import library, then you are just
going to confuse people.
You wrote this:
<quote>
The import library used to "statically" link to a dll does contain the
appropriate code to dynamically link to the dll and bind your names to it.
</quote>
Every sane developer would read that and think that you are talking
about machine code in the import library. Not letters, numbers and symbols.
Quote
So Import libraries do contain "code". That "code" by its presence and
content does exactly as I meant to say.
Import libraries do not contain commands.
Actually, import libraries do indeed contain code. Here I am using code
to mean machine instructions that an x86 CPU can process and execute.
The code is a jump to an address. However, that code only ends up in the
code segment of the executable if the DLL author is stuck in the year
1994. For most DLLs, the code in the import library is discarded, and
the linker inserts a more efficient call.
See this article by Matt Pietrek, specifically the section on importing
functions. Pietrek is a very smart guy. It is well worth it to read just
about everything he writes.
msdn.microsoft.com/msdnmag/issues/02/02/PE/
He also has a follow up article here:
msdn.microsoft.com/msdnmag/issues/02/03/PE2/default.aspx
H^2
 

Re:Re: Static linked library in Package not allowed

Valence wrote:
Quote
If arbitrarily picking a name for it, Richter is as good as any. But I think
the majority rules, in this case, with reason.
I don't know where you live, but I live in the United States. Now, I may
not know everything, but one thing I have learned from being a citizen
of this country is that being in the majority doesn't make you right.
H^2