What is error: link: fatal error LINK1104

I have been working with PGI V7.1.2 for a while.
Recently, I got this error message:

link: fatal error LINK1104: cannot open ‘TEMPFILE’

I do not know what this is, and do not know how to solve this problem.
Please advice me. Thanks!

Hi YWu,

Check your permissions on the “temp” directory as defined in your environment by the “TEMP” variable (“env $TEMP”). You most likely don’t have write permissions. Also, try setting TEMP to a directory you know you have permissions, such as your local documents directory.

Hope this helps,
Mat

Hi, Mat,

Thanks. I do have TEMP at C:\Documents and Settings\ywu\Local Settings\Temp. In the “Environment variables” settings, one is for “user variable”, one for “system variable”. I have TEMP for both. The “TEMP” for system is located at C:\Windows\Temp. I can create file in this directory. Are these two conflict.

Ywu

Hi Ywu,

The “TEMP” environment variable can be set to any directory, but it should only be a single directory. So I wasn’t quite sure what you meant by having two TEMP directories.

What is the output of “echo $TEMP” (or “echo %TEMP%” if you’re using a DOS shell)? And please confirm that you do have permissions to write to this directory.

  • Mat

Hi, Mat,

It is C:\Documents and Settings\ywu\Local Settings\Temp
I definitely have right to write a file to this directory.
It worked before. The problem occurred recently after an update by a computer manager. I am wondering this is caused by the update.

Hi Ywu,

Very possible. According to Microsoft’s Developer Web Site (See:
http://msdn.microsoft.com/en-us/library/ts7eyw4s(vs.71).aspx), a LINK 1004 error is caused by one of the following problems:

Visual C++ Concepts: Building a C/C++ Program
Linker Tools Error LNK1104

cannot open file ‘filename’

The tool could not open the given file.

Possible causes

  • Not enough disk space.
  • File does not exist. For example, you will get this error if you try to use the PGINSTRUMENT parameter to the /LTCG linker option on a machine with a 32-bit operating system.
  • When specifying libraries in a project’s property pages dialog box, library names should be separated by spaces (and not commas).
  • Incorrect filename or path.
  • Invalid drive specification.
  • Insufficient file permissions.
  • Path for filename expands to more than 260 characters.
  • If the given file is named LNKn, which is a filename generated by the linker for a temporary file, the directory specified in the TMP environment variable may not exist, or more than one directory is specified for the TMP environment variable. (Only one directory path should be specified for the TMP environment variable.)
  • If the error message occurs for a library name, and you recently ported the .mak file from a previous Microsoft Visual C++ development system, the library may no longer be valid. Ensure that the library still exists in this circumstance.
  • Another program may have the file open and the linker cannot write to it.
  • Incorrect LIB environment variable. For information on how to update the LIB environment variable, see VC++ Directories, Projects, Options Dialog Box. Make sure any directories with libraries you need are listed here.

The linker uses temporary files in several cases. Even if you have sufficient disk space, a very large link can deplete or fragment the address space. To address this issue:

  • Use /opt:noref; doing transitive comdat elimination reads all the object files multiple times.
  • Upgrade to Windows XP.

Since we’ve confirmed that you have the correct directory name, it’s not too long, has the correct permissions and the TMP variable is set to a single directory, make sure that you have enough disk space. Also, try deleting all the files in your TMP directory to make sure that the tempfile the linker wants to use is not locked.

I saw another post when searching this problem where the user suggested the Visual Studio installation got corrupted. I don’t know how valid this is but as a last resort, you can try uninstalling and then reinstalling your installation to see if you recent update somehow corrupted the Microsoft Open Tools that accompany the PGI compilers.

  • Mat