[M3devel] dynamic linking, stanalone()?
Jay
jayk123 at hotmail.com
Mon Jan 14 00:43:41 CET 2008
Dynamic linking vs. "standalone". How does that work? On Posix, with ld, etc.?
I understand fully how it works on NT386 and will explain, as a jumping off point
for explanation and analogies.
Windows has "import .libs" and regular old "static .libs".
In reality it has import .objs and regular .objs, and a .lib is a collection of .objs,
and can contain a mix, but this is not well known. Usually a .lib only has all one type
or all the other type. Actually older import .libs are just kind of wierd and drive
the linker in odd roundabout ways that end up doing the right thing, I guess
without the linker knowing much. Current Cygwin/Mingwin ld/dlltool import libs
I think are still odd. And large. And besides, they seem buggy but tht's a tangent.
Look at msvcrt.lib. It contains static startup code and imports.
There is no seperate crt0.o file on Windows.
USUALLY people only build one .lib type or another.
However the Modula-3 system has a clever innovation. It always builds both.
This retains flexibility in how the clients are built.
cm3.exe links to m3core/libm3 statically, most other folks dynamically.
It is ROUGHLY like so:
lib /out:foo.lib.sa objects...
sa for standalone
link /out:foo.dll objects...
as a by-product of the link, foo.lib an import .lib is produced
When you go to link, you give the linker, well, let's say, full paths.
To foo.lib or foo.lib.sa, or whatever mix.
(or leaf only paths and the LIB environment variable is searched, kind
of like $PATH)
In "Posix" I know there is foo.a and foo.so.
But an .so is a .dll. An .a is? Either?
And the third one is?
To some extent, no matter.
I THINK it goes like this for Cygwin/MinGWin:
ar foo.lib.sa objects
ld -o foo.dll --out-imlib foo.lib
but it's not quite working for me currently.
I'm backtracking to get to an earlier version of my config file that was.
I should probably break down and use dlltool.
And I can read the docs, of course. I do so.
And search the web.
I have avoided using anything that isn't already a configuration variable.
That is, I use gcc instead of ld for example.
This is dumb of me I realize.
ld gave me fits also on MacOSX but on Windows it should be more viable,
fewer arcane details as to what to link in. e.g. I believe on "Posix", the entry
point of a file is whatever .o is linked first. Chose carefully.
On Windows it is seperately specified and the order of the link command doesn't
affect it (though still has other subtle affects). And it is usually buried in a .lib,
fewer files to chose between.
- Jay
_________________________________________________________________
Share life as it happens with the new Windows Live.
http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20080113/40818c88/attachment-0001.html>
More information about the M3devel
mailing list