home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!lrw.com!leichter
- From: leichter@lrw.com (Jerry Leichter)
- Newsgroups: comp.os.vms
- Subject: RE: Linking C programs
- Message-ID: <9208281556.AA13265@uu3.psi.com>
- Date: 28 Aug 92 15:46:09 GMT
- Sender: usenet@ucbvax.BERKELEY.EDU
- Organization: The Internet
- Lines: 66
-
-
- I have seen many postings on this list regarding linking a C object
- against the sharable image, VAXCTRL.EXE. This involves creating a
- linker option file (.OPT), and specifying this option file on the
- command line when linking to create a much smaller executable image. I
- have used this method for some time now, and it works quite well...
-
- A short time ago, I saw a response to one of these questions which
- pointed out where the REAL problem is, and why we need to do this in
- the first place. It was pointed out that since the CRTL wasn't in the
- sharable image library, IMAGELIB.OLB, and therefore, we must provide a
- pointer to it implicitly. Well, why not put it there?? To do this,
- just add it to the image library:
-
- $ SET DEF SYS$LIBRARY
- $ LIB/SHARE IMAGELIB SYS$SHARE:VAXCRTL.EXE
-
- Now you have to remove the logical name pointer to VAXCRTL.OLB. Do a
- SH LOG LNK* <enter>. There will be a reference that looks something
- like this:
-
- LNK$LIBRARY = "SYS$LIBRARY:VAXCRTL"
-
- If you have curses and/or g_float support, it may be LNK$LIBRARY_1 or
- _2. be sure to DEASS/SYS the logical name that points to VAXCRTL.
- Also, you might also wish to remove/comment out the entry which
- defines it in the startup command procedure so that if the system is
- rebooted, users will not go back to linking against the regular
- library.
-
- If anyone out there might have any comments or warnings on this please
- let me know... As yet, I have not seen/heard of any problems by doing
- this...
-
- Periodically, someone proposes this. Usually, the posting proposing it asks
- why, after doing this, C programs fail to work properly.
-
- There is an old (day-1) bug in the Linker which makes this fail to work.
- I can never remember the exact bug, but the effect it has is that references
- to stdin and friends are not resolved consistently: You end up with multiple
- instances of the pre-declared data structures defining the standard input and
- output files. I/O to them will not work correctly.
-
- As part of the changeover for the VAX C RTL to the DEC C RTL, I gather this
- bug was supposed to finally be fixed. I seem to recall a vague reference to
- a bug fix that sounded as if it could be related in the V5.5 Release Notes.
- So it's POSSIBLE that this will work in recent VMS versions. It definitely
- will NOT work in older VMS versions.
-
- Of course, the other problem - that you will then have names like "OPEN"
- defined in your system-wide copy of IMAGELIB, which may cause all sorts of
- amusing problems for programmers in other languages - remains. DEC C will
- presumably do things like:
-
- #define fopen DECC$FOPEN
-
- in stdio.h. ANSI requires that the name "fopen" be meaningful even if stdio.h
- isn't included (though such use is discouraged), or the programmer adds
-
- #undef fopen
-
- so the problem won't go away completely. My guess would be that, if you
- insist on playing games like this, you'll be stuck with searching some
- other library explicitly.
- -- Jerry
-
-