From: | root@jacob.remcomp.fr (root) |
Newsgroups: | comp.compilers |
Date: | 2 Feb 1997 21:18:41 -0500 |
Organization: | Compilers Central |
References: | 97-01-183 97-01-189 97-01-212 |
Keywords: | linker |
Jason Spielman <jason@interval.net> wrote:
>Q: How does one link several object files into a single object file
> or library, where symbols are resolved locally as much as possible,
> and where only selected symbols are exported/exposed/made public?
Under Windows (Win95, Windows NT or Windows 3.11) you can build a DLL
(Dynamic Linked Library). This type of library will ONLY export the
definitions specified in the .def (definitions) file. This is a plain
ASCII file. You will ONLY export the symbols you specify, just as you
want.
: [What gets me is that implementing this stuff shouldn't be very hard. Don't
: know why it hasn't become more popular. -John]
It is VERY popular John. DLLs are a STANDARD way of doing this since
1990 or so for windows developers. It is a pity this is not very well
known outside the windows programmer's world. You specify an ascii
file roughly like:
LIBRARY MyLibrary.dll
EXPORTS MyFunction@1
MyBuggedFunction@2
MyDebuggedFunction@3
etc etc.
This functions will be visible to the loader, that searches the
corresponding dll and link it to the executable being loaded. All
OTHER symbols in the dll file are INVISIBLE. There is no way to use
them. In the executable you specify which functions you import from
the dll either with a .def file with the IMPORTS keyword, or with a
special declaration in the function definition. At link time you use
an Import Library, that contains stubs for building the import table.
The advantage of developing this way, is that you can change the dll
without touching the executable. If you do not change the interface
definition between the dll and its client, you can ship a new version
of the dll to clients in the field without shipping any other thing.
For references, documentation,etc please read ANY serious book about
windows (3.1 95 NT ANY will do) The literature is copious.
There are drawbacks of course. As with all in life, there is no silver
bullet. If you change the interface for instance, hairy problems can
appear if you have different versions of dll in the PATH variable,
etc. See any discussion of dynamic linking in any windows book.
--
Jacob Navia Logiciels/Informatique
41 rue Maurice Ravel Tel 01 48.23.51.44
93430 Villetaneuse Fax 01 48.23.95.39
France
[Do DLLs still have to work with no static data? I recall that as being
one of their more inconvenient shortcomings. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.