Like Tree1Likes

VC 2008 linker error

This is a discussion on VC 2008 linker error within the C++ Programming forums, part of the General Programming Boards category; Having a little problem with VC 2008 Express. I have used it on various computers from XP x86 to 7 ...

  1. #1
    Registered User Holmes's Avatar
    Join Date
    May 2011
    Posts
    9

    VC 2008 linker error

    Having a little problem with VC 2008 Express. I have used it on various computers from XP x86 to 7 x64, but recently installed it on a newer Win 7 x64 computer and ran into an annoying problem. Every time I try to build any project, even a simple HelloWorld project, the linker chokes with "fatal error LNK1181: cannot open input file '.\Release\stdafx.obj'".

    I don't have any additional dependencies or include directories added yet as this is a clean install. I do have the Server 2008 SDK installed, but I was having this problem with the standard Express SDK alone.

    Here's the build log of a HelloWorld sample:
    Build Log
    Rebuild started: Project: HelloWorld, Configuration: Debug|Win32

    Command Lines
    Creating temporary file "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\RSP00000 868046176.rsp" with contents
    [
    /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\HelloWorld.cpp"
    ]
    Creating command line "cl.exe @"c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\RSP00000 868046176.rsp" /nologo /errorReportrompt"
    Creating temporary file "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\RSP00000 968046176.rsp" with contents
    [
    /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Yc"stdafx.h" /Fp"Debug\HelloWorld.pch" /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\stdafx.cpp"
    ]
    Creating command line "cl.exe @"c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\RSP00000 968046176.rsp" /nologo /errorReportrompt"
    Creating temporary file "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\TMP00000 A68046176.tmp" with contents
    [
    1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ ".\\Debug\\HelloWorld.exe.embed.manifest"
    ]
    Creating command line "rc.exe /fo".\Debug\HelloWorld.exe.embed.manifest.res" "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\TMP00000 A68046176.tmp""
    Creating temporary file "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\RSP00000 B68046176.rsp" with contents
    [
    /OUT:"C:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\Debug\HelloWorld.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"Debug\HelloWorld.exe.intermediate.ma nifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\Debug\HelloWorld.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

    ".\Debug\stdafx.obj"

    ".\Debug\HelloWorld.obj"

    ".\Debug\HelloWorld.exe.embed.manifest.res"
    ]
    Creating command line "link.exe @"c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\RSP00000 B68046176.rsp" /NOLOGO /ERRORREPORT:PROMPT"
    Output Window
    Compiling...
    Compiling...
    Compiling manifest to resources...
    Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
    Copyright (C) Microsoft Corporation. All rights reserved.
    Linking...
    LINK : fatal error LNK1104: cannot open file '.\Debug\stdafx.obj'
    Results
    Build log was saved at "file://c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\BuildLog .htm"
    HelloWorld - 1 error(s), 0 warning(s)
    Google hasn't been too helpful on this. Could someone please tell me what the problem is?

  2. #2
    template<typename T> threahdead's Avatar
    Join Date
    Sep 2002
    Posts
    214
    Try creating the C++ project as an empty project. This can be done in the C++ project creation dialog.

  3. #3
    Registered User Holmes's Avatar
    Join Date
    May 2011
    Posts
    9
    Thanks for the reply.

    When I create an empty project or even just set the 'Create/Use Precompiled Headers' option to 'Not Using Precompiled Headers' in the project options, it dies with
    LINK : fatal error LNK1104: cannot open file '.\Debug\HelloWorld.obj'
    or
    LINK : fatal error LNK1104: cannot open file '.\Release\HelloWorld.obj'
    I've tried everything I could find about the problem on Google in the first 6 or 7 pages and nothing is relevant/working. Even a few re-installs didn't work.

    I'm installing from a burned ISO with the complete VS 2008 suite on it and have also installed C# and VB from the same image & they work fine. I don't get any installation errors or warnings.

    The target directory isn't read-only and changing it to Desktop or 'C:\Users\Code' didn't work. Creating a new user account didn't work.

    I figure it is some stupid little thing I'm missing but I've been fighting with this for a week now. I really need this working on this system.

    Any other idea?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    Do you still see this in the compile log?
    Command Lines
    Creating temporary file "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\Debug\RSP00000 868046176.rsp" with contents
    [
    /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\HelloWorld.cpp"
    ]
    Did you choose the "rebuild all" when you started the new project?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User Holmes's Avatar
    Join Date
    May 2011
    Posts
    9
    I have tried "rebuild all" and just building the .cpp file (after creating a new empty project again). The results are the same:
    Build Log
    Rebuild started: Project: HelloWorld2, Configuration: Debug|Win32

    Command Lines
    Creating temporary file "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld2\HelloWorld2\Debug\RSP000 00463682240.rsp" with contents
    [
    /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\HelloWorld.cpp"
    ]
    Creating command line "cl.exe @"c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld2\HelloWorld2\Debug\RSP000 00463682240.rsp" /nologo /errorReportrompt"
    Creating temporary file "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld2\HelloWorld2\Debug\TMP000 00563682240.tmp" with contents
    [
    1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ ".\\Debug\\HelloWorld2.exe.embed.manifest"
    ]
    Creating command line "rc.exe /fo".\Debug\HelloWorld2.exe.embed.manifest.res" "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld2\HelloWorld2\Debug\TMP000 00563682240.tmp""
    Creating temporary file "c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld2\HelloWorld2\Debug\RSP000 00663682240.rsp" with contents
    [
    /OUT:"C:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld2\Debug\HelloWorld2.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"Debug\HelloWorld2.exe.intermediate.m anifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld2\Debug\HelloWorld2.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

    ".\Debug\HelloWorld.obj"

    ".\Debug\HelloWorld2.exe.embed.manifest.res"
    ]
    Creating command line "link.exe @"c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld2\HelloWorld2\Debug\RSP000 00663682240.rsp" /NOLOGO /ERRORREPORT:PROMPT"
    Output Window
    Compiling...
    Compiling manifest to resources...
    Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
    Copyright (C) Microsoft Corporation. All rights reserved.
    Linking...
    LINK : fatal error LNK1104: cannot open file '.\Debug\HelloWorld.obj'
    Results
    Build log was saved at "file://c:\Users\Code\Documents\Visual Studio 2008\Projects\HelloWorld2\HelloWorld2\Debug\BuildL og.htm"
    HelloWorld2 - 1 error(s), 0 warning(s)

  6. #6
    Registered User Holmes's Avatar
    Join Date
    May 2011
    Posts
    9
    I uninstalled VC++ (again), deleted every folder and registry key that I could find related to it, rebooted and did a fresh install (again). I still have this problem after all that.

    I was going to zip a sample project and attach it here but the forum doesn't seem to like .zip files (isn't that strange?) so I can't do that.

    Is there any other information I could provide that might shed some light on this?

  7. #7
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    change the extension of your zip file to a text file .txt and then you can upload.

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    In your shoes, I wold move my source code to a safe folder, trash the existing project and rebuild it from scratch, then drop the files back in and add them to the project.

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    And just for fun I'd also disable precompiled headers if you've got it enabled. (Granted it shouldn't be looking for stdafx.obj I don't think, but just the name "stdafx" sends shivers up my spine.)

  10. #10
    Registered User Holmes's Avatar
    Join Date
    May 2011
    Posts
    9
    Quote Originally Posted by Raigne
    change the extension of your zip file to a text file .txt and then you can upload.
    Thanks, attached a sample project this way. Just rename back to .zip.
    Quote Originally Posted by CommonTater
    In your shoes, I wold move my source code to a safe folder, trash the existing project and rebuild it from scratch, then drop the files back in and add them to the project.
    This isn't just one project giving me problems, its EVERY project I create or import (even ones that used to work fine).
    Quote Originally Posted by tabstop
    And just for fun I'd also disable precompiled headers if you've got it enabled. (Granted it shouldn't be looking for stdafx.obj I don't think, but just the name "stdafx" sends shivers up my spine.)
    Yes, I have tried that but it makes no difference.

    I'm really at a loss here with what can be causing this. Worked fine every other time I've installed it.

    Thanks to everyone for the help so far.
    Attached Files Attached Files

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Does a build produce any OBJ files at all? (ie can the OBJ file not be opened because it was not built?)

    It could be because you using the /P directive.

    Quote Originally Posted by MSDN
    This option suppresses compilation; the compiler does not produce an .OBJ file
    Project Properties -> Configuration Properties -> C/C++ -> Preprocessor,

    'Generate Preprocessed File' == 'no'
    Salem likes this.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  12. #12
    Registered User Holmes's Avatar
    Join Date
    May 2011
    Posts
    9
    No, the object files are not being generated. I watched the directories during a builds just to be sure they weren't being created and then deleted for some reason. There is no sign of them during or after a build.

    And I have 'Generate Preprocessed File' set to No on all current test projects now so that's not it.

    I'd think it was just a corrupt installation if I hadn't already re-installed it 15 times.

  13. #13
    Registered User
    Join Date
    May 2009
    Posts
    2,493
    Quote Originally Posted by Holmes View Post
    I'd think it was just a corrupt installation if I hadn't already re-installed it 15 times.
    Did you run windows update after installing to confirm there is no patch needed to run under Windows 7?

    Tim S.

  14. #14
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    There are no patches needed.
    I've run VS10 under Win7 with no updates and with SP1 and no updates. Runs fine.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    Registered User Holmes's Avatar
    Join Date
    May 2011
    Posts
    9
    Yea I have this installed on 2 other Windows 7 computers right now and it's working fine on those without any updates or changes. I really need it working on this one also.

    I've tried running it in compatibility mode for everything from Windows 2k to Vista SP2 and nothing helped.

    I've been looking for differences between this computer and the other 2 and I can't really find any that would be relevant. I think since I have the same directory structures with this as I do the other ones that I'm going to try copying the directories from one of the others one to this one and see what happens. I don't expect any changes though.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LINK2001 Error? VS 2008 C++
    By kazzal in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2009, 02:23 AM
  2. Linker Error
    By herWter in forum C++ Programming
    Replies: 11
    Last Post: 08-10-2008, 06:22 AM
  3. Linking error. VC++ 2008.
    By Raigne in forum C++ Programming
    Replies: 6
    Last Post: 04-21-2008, 09:49 PM
  4. linker error
    By :::::: in forum C++ Programming
    Replies: 1
    Last Post: 04-09-2003, 05:00 PM
  5. Linker error
    By dv007 in forum C Programming
    Replies: 8
    Last Post: 06-07-2002, 02:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21