Thread: windows header files not linking correctly

  1. #1
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594

    windows header files not linking correctly

    I am currently working on a project with several people, and one individual is not able to successfully build the main solution. We are developing with VS.Net 2003. It seems as if this individual's system does not include the windows headers correctly. We are using the standards stdafx.h which looks like such:
    Code:
    #pragma once
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    #include <stdlib.h>
    #include <malloc.h>
    #include <memory.h>
    #include <tchar.h>
    The initial error was "missing ; before hWnd" which was because it couldn't find the definition of an HWND. I kept knocking out errors by explicitly including windows headers such as winbase.h, winnt.h, windef.h, and a few others. Each addition got rid of some errors, but I eventually got to a point where I had a circular dependency with windef.h and winnt.h, so I can't even hack a solution.

    Any insight as to what the problem may be would be greatly appreciated.

  2. #2
    Chief Code Coloniser!
    Join Date
    Apr 2005
    Posts
    121
    Sounds very strange. You sure you're all working off the same version of the compiler?

    I'm guessing that if this builds on most people's machines, and it's just failing on one, that machine's environment is not setup properly.

    Perhaps a good place to look is the "include" directories settings on the culprit machine. He/she may have a different search path order than the rest of you?

  3. #3
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    We found the problem: the linker was including the wrong header because of naming conflicts. We have our own specialized string class apptly put into a "string.h" file, and some of the std containers we were using were confused when they got the wrong string.h. The compiler/linker never told me that it had two string.h's to look at. This was easily solved by changing our string's header file. A silly and embarrassing mistake.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Header Files
    By devarishi in forum C Programming
    Replies: 8
    Last Post: 12-10-2008, 04:53 PM
  2. Replies: 4
    Last Post: 12-14-2005, 02:21 PM
  3. Header Files
    By Volair in forum C Programming
    Replies: 2
    Last Post: 12-09-2005, 10:51 AM
  4. Linking Error Whenever I Tried To Use Header Files
    By javacvb in forum C++ Programming
    Replies: 5
    Last Post: 12-16-2003, 11:46 AM
  5. more header files
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-28-2001, 01:56 PM