Pre-compiled header commands

Sysprogs forums Forums VisualGDB Pre-compiled header commands

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #762
    dvdevore
    Participant

    Hello,

    I’m trying to get my VGDB projects to compile precompiled headers, similar to our Win configurations. I know VGDB does not support pre-compiled headers, and I have read the post from last year here:
    viewtopic.php?f=5&t=2769

    So I take it that it is possible, but I’m not quite sure where to actually run the commands to generate the pre-compiled header for each project (StdAfx.h.gch).

    Is it possible to put the commands below somewhere in the Makefile?
    StdAfx.h.gch: StdAfx.h
    $(CXX) $(CXXFLAGS) -c StdAfx.h -o StdAfx.h.gch
    $(CXX) $(CXXFLAGS) -MM StdAfx.h > StdAfx.h.dep

    I’m new to Linux/gcc and obviously VGDB, so any help is much appreciated 😛

    #3003
    support
    Keymaster

    Hi,

    You could modify the makefile to build/use precompiled headers manually. Add the following lines to it before the FileSpecificTemplates line:

    PRECOMPILED_HEADER_FILE := stdafx.h.gch
    stdafx.h.gch: $(all_make_files) stdafx.h
    $(CXX) $(CXXFLAGS) -c stdafx.h -o stdafx.h.gch -MD -MF $(BINARYDIR)/stdafx.dep
    
    -include $(BINARYDIR)/stdafx.dep
    

    Then modify FileSpecificTemplates this way:

    $(BINARYDIR)/%.o : %.cpp $(all_make_files) $(PRECOMPILED_HEADER_FILE) |$(BINARYDIR)
    $(CXX) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep)
    

    Note that this solution will have one major disadvantage: The precompiled header file will be shared between debug/release builds, so you will need to delete it before building the other configuration. You can fix it by creating the gch file inside $(BINARYDIR), but then you will need to add it to the beginning of the include directory list and ensure it is always there before the '.' directory.

    #3004
    dvdevore
    Participant

    Thank you for your help :mrgreen:

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.