FIX: Custom Build Generates LNK1104 for Project Build from IDE (149496)



The information in this article applies to:

  • Microsoft Visual Studio, Enterprise Edition 6.0

This article was previously published under Q149496

SYMPTOMS

A custom build produces a LNK1104 error when you are building project from Developer Studio.

WORKAROUND

There are two workarounds:

  • Close the workspace after entering the Custom Build in Step 5 of the "Steps to Reproduce Problem" section of this article. Open the project again. The build will be successful this time. -or-

  • Go to an MS-DOS command prompt, and use NMAKE to build project.

STATUS

Microsoft has confirmed this to be bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 5.0.

MORE INFORMATION

Steps to Reproduce Problem

  1. Create two directories:
       \Junk
       \Junk\Src
  2. Create a text file named \Junk\Src\Source.cs that has the following contents:
       #include <stdio.h>0
    
       void main( void )
       {
         printf("Custom build options has a bug\n");
       }
  3. In Developer Studio, on the File menu, choose New, and then choose Project Workspace. Select the Console Application type in the New Project Workspace dialog box. Type a name (for example, test1), and then the project location should read:
       \Junk\Src\Test
    
       Create the project.
  4. On the Insert menu, choose Files into project, and type ..\Source.cs for the file name. Then click OK. On the Insert menu, choose Files into project again. Type Source.c for the file name, and click OK. Developer Studio will say this file doesn't exist and ask if you want to add it as a reference; click Yes.
  5. On the Build menu, choose Settings. Expand both the Debug and Release branches of Project Settings by clicking the plus sign (+) next to each project target. Select Source.cs under Debug and Control. Then click Source.cs under Release. Choose the Custom Build tab.
  6. Type "The proof is in the build" for the Description. Click in the first line of Build commands. Type the following (use macro menus if you wish):
          copy ..\$(InputName).cs $(ProjDir)\$(InputName).c
  7. Click in the first line of Output files. Type the following:
          $(ProjDir)\$(InputName).c
  8. Click OK.
  9. Build the project. It will do the custom build step but it will not follow it up with a compile of the .c file and a linker error LNK1104 (cannot open ".\Debug\Source.obj") will be generated. Note that choosing to Save all after setting the custom build option in Step 5 has the same effect.

Modification Type:MinorLast Reviewed:8/11/2005
Keywords:kbbug kbfix kbide kbVC500fix KB149496 kbAudDeveloper