[an error occurred while processing this directive] Node:Linker accesses other drives, Next:, Previous:ThinkPad, Up:Trouble

6.13 Why does the Linker Access my CD Drive or the network?

Q: Why is it that every time I link a program, the CD-ROM drive is accessed?

Q: Whenever I link programs, GCC invokes something called `collect2' which accesses my LAN when it runs. Why?

A: CD-ROMs or other drives being accessed during linking is due to a bug in Binutils 2.7 and in an early release of Binutils 2.8.1: the linker would always try to look for its script djgpp.djl in a certain directory on the D: or E: drive (the former in Binutils 2.7, the latter in 2.8.1), no matter which disk uses that letter (these accesses usually go unnoticed with hard disks, but are visible with CD-ROMs, Zip drives, or other slower devices). Download and install the latest bnuNNNb.zip archive you can find on SimTel.NET mirrors, and the problem should go away.

If collect2 seems to be accessing the network, it is due to a bug in the early ports of GCC 2.95: if a root directory of some drive appeared in your PATH setting, collect2 would try to access a file whose name has two slashes, like C:\/foo. This causes Windows 9X to treat this as a UNC (a.k.a. network share) name, and search the network for such a server which exports this share. The ports of GCC 2.95.1 and later don't have this bug.

You can see which directories on what drives does the linker try to access by passing the --verbose option to the linker. Here's an example:

 gcc -o hello.exe hello.o -Xlinker --verbose > linker.log

This redirects the linker log to a file which you can then examine. Since the list of directories accessed by the linker doesn't depend on the program being linked, you can try this with any trivial program.

Sometimes, accesses to other drives come from some over-zealous anti-virus software. If you have one of these installed, check out its options: perhaps there are some superflous drive letters there.

[an error occurred while processing this directive]