[M3devel] dynamic linking, stanalone()?

Jay jayk123 at hotmail.com
Mon Jan 14 00:53:58 CET 2008


Nevermind, I'll figure it out.
I am going to try dlltool.
Currently it SEEMS like references are to _Foo but defintions are Foo.
Of course, leading underscores always confuse. Sometimes they are added, sometimes they are removed, sometimes they must match. It stinks a little bit. At least on x86 Windows. Usually it is well hidden. COULD be a disagreement between Cygwin cm3cg and mingwin as/ld..though given that things were working..I don't know. I should try the mingwin sh/make/sed...

 - Jay
From: jayk123 at hotmail.com
To: m3devel at elegosoft.com
Date: Sun, 13 Jan 2008 23:43:41 +0000
Subject: [M3devel] dynamic linking, stanalone()?







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. Start sharing!

_________________________________________________________________
Put your friends on the big screen with Windows Vista® + Windows Live™.
http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_012008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20080113/a5b96d4d/attachment-0002.html>


More information about the M3devel mailing list