visual-studiolinkervcbuild

What does this error message mean: LINK : fatal error LNK1104: cannot open file 'TEMPFILE'


I'm building a C program with Visual Studio 2008, from the command line.

vcbuild /logcommands foo.vcproj

From the GUI, the build works fine. But from the command line, the build fails at the link stage, with these error mesages:

Linking...
   Creating library c:\foo\out\foo.lib and object c:\foo\out\foo.exp
Generating code
Finished generating code
LINK : fatal error LNK1104: cannot open file 'TEMPFILE'
Build log was saved at "file://c:\foo\out\BuildLog.htm"

What's this TEMPFILE, and how do I fix the build?


Solution

  • The linker is trying to create a temporary file in the directory indicated by the TMP environment variable. Make sure that TMP is set and that it points to a directory where the linker can create files and that has enough disk space. E.g.,

    set TMP=%HOMEDRIVE%%HOMEPATH%\Local Settings\Temp
    vcbuild /logcommands foo.vcproj
    

    (Found in the SCons FAQ of all places. My build scripts were messing up with TMP before calling vcbuild, for some unfathomable reason.)