Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 621231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:51:06+00:00 2026-05-13T18:51:06+00:00

I have the following makefile (fragment) SRC_DIR = src OBJ_DIR = obj DEP_DIR =

  • 0

I have the following makefile (fragment)

SRC_DIR     = src
OBJ_DIR     = obj
DEP_DIR     = dep
BIN_DIR     = .
SRC_FILES  := $(wildcard $(SRC_DIR)/*.cpp)
OBJ_FILES  := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES))
DEP_FILES  := $(patsubst $(SRC_DIR)/%.cpp,$(DEP_DIR)/%.d,$(SRC_FILES))

# Development build directive
dev: $(DEP_FILES) $(OBJ_FILES)
  $(CPPC) $(LIBS) $(FLAGS_DEV) $(OBJ_FILES) -o $(BIN_DIR)/$(PROJECT)

# Object file directives
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(DEP_DIR)/%.d
  $(CPPC) -c $(FLAGS_DEV) $< -o $@

# Dependency directives
$(DEP_DIR)/%.d: $(SRC_DIR)/%.cpp
  $(CPPC) -MM -MD $< -o $@

include $(DEP_FILES)

When I run make dev I see the following

makefile:59: dep/area.d: No such file or directory
makefile:59: dep/avatar.d: No such file or directory
makefile:59: dep/board.d: No such file or directory
makefile:59: dep/socket.d: No such file or directory
g++ -MM -MD src/socket.cpp -o dep/socket.d
g++ -MM -MD src/board.cpp -o dep/board.d
g++ -MM -MD src/avatar.cpp -o dep/avatar.d
g++ -MM -MD src/area.cpp -o dep/area.d
g++ -c -ggdb3 -ansi -Wall -Werror -pedantic-errors src/area.cpp -o obj/area.o
g++ -c -ggdb3 -ansi -Wall -Werror -pedantic-errors src/avatar.cpp -o obj/avatar.o
g++ -c -ggdb3 -ansi -Wall -Werror -pedantic-errors src/board.cpp -o obj/board.o
g++ -c -ggdb3 -ansi -Wall -Werror -pedantic-errors src/socket.cpp -o obj/socket.o
g++ -ggdb3 -ansi -Wall -Werror -pedantic-errors obj/area.o obj/avatar.o obj/board.o obj/socket.o  -o ./game

When changing src/socket.h (a file upon which the others all depend) and running make, I expected it would rebuild the entire project, but it only emits one action

g++ -ggdb3 -ansi -Wall -Werror -pedantic-errors obj/area.o obj/avatar.o obj/board.o obj/socket.o  -o ./game

I believe I’m generating the automatic dependencies correctly – so I get the sense I’m simply not using them properly. Where have I gone wrong? I know the makefile:59:... errors are a clue, but I’ve never worked with auto generated dependencies before.

Thanks in advance; Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:51:07+00:00Added an answer on May 13, 2026 at 6:51 pm

    Unfortunately, your *.d files aren’t getting their full dependencies; they depend on all of the header files, too. One way to fix this would be to add an extra line to the %.d directive:

    # Dependency directives
    $(DEP_DIR)/%.d: $(SRC_DIR)/%.cpp
      $(CPPC) -MM -MD $< -o $@
      sed -i 'p;s|$(OBJ_DIR)/\(.*\)\.o:|$(DEP_DIR)/\1.d:|' $@
    

    If the -i scares you, you could try sponge (in the moreutils package on my distribution).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 377k
  • Answers 377k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes it has real garbage collection. MonoTouch is based on… May 14, 2026 at 9:03 pm
  • Editorial Team
    Editorial Team added an answer A "normal" Java program cannot force the garbage collector to… May 14, 2026 at 9:03 pm
  • Editorial Team
    Editorial Team added an answer Try this one (this will match everything that should be… May 14, 2026 at 9:03 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.