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 8405573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:53:05+00:00 2026-06-09T22:53:05+00:00

As part of the makefile i’d like to produce either a debug or release

  • 0

As part of the makefile i’d like to produce either a debug or release version of the target.

Functionally, everything is working, however, i am getting warnings when running make

 12 SRC := $(shell echo src/*.cpp)
 13 SRC += $(shell echo $(TEST_ROOT)/*.cpp)
 14 
 15 D_OBJECTS = $(SRC:.cpp=.o)       # same objects will need to be built differently
 16 R_OBJECTS = $(SRC:.cpp=.o)       # same objects will need to be built differently

 22 all: $(TARGET)
 23 
 25 $(TARGET): $(D_OBJECTS)
 26   $(CC) $(D_OBJECTS) -o $(TARGET)
 27 
 28 $(D_OBJECTS) : %.o: %.cpp                     # ----- run with debug flags 
 29   $(CC) $(COMMON_FLAGS) $(DEBUG_FLAGS) -c $< -o $@
 30 
 31 release: $(R_OBJECTS)
 32   $(CC) $(R_OBJECTS) -o $(TARGET)
 33 
 34 $(R_OBJECTS) : %.o: %.cpp                     # ----- run with release flags
 35   $(CC) $(COMMON_FLAGS) $(RELEASE_FLAGS) -c $< -o $@

When i make i get debug version, when i make release i get release version.

But i also get warnings:

Makefile:35: warning: overriding commands for target `src/Timer.o'
Makefile:29: warning: ignoring old commands for target `src/Timer.o'
Makefile:35: warning: overriding commands for target `test/TimerTest.o'
Makefile:29: warning: ignoring old commands for target `test/TimerTest.o'

With this 2 questions:

  1. Any way to ignore the warnings
  2. Am i doing things right? What changes are needed?
  • 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-06-09T22:53:06+00:00Added an answer on June 9, 2026 at 10:53 pm

    One of the most common ways for doing this is to put the release objects and the debug objects in separate subdirectories. That way you don’t get redefinitions for the rules for an object, since they will have different names. Something like this:

    D_OBJECTS=$(SRC:%.cpp=debug/%.o)
    R_OBJECTS=$(SRC:%.cpp=release/%.o)
    
    RTARGET = a.out
    DTARGET = a.out.debug
    
    all : dirs $(RTARGET)
    
    debug : dirs $(DTARGET)
    
    dirs :
        @mkdir -p debug release
    
    debug/%.o : %.c
        $(CC) $(DEBUG_CFLAGS) -o $@ -c $<
    
    release/%.o : %.c
        $(CC) $(RELEASE_CFLAGS) -o $@ -c $<
    
    $(DTARGET) : $(D_OBJECTS)
        $(CC) $(DEBUG_CFLAGS) -o $@ $(D_OBJECTS)
    
    $(RTARGET) : $(R_OBJECTS)
        $(CC) $(RELEASE_CFLAGS) -o $@ $(R_OBJECTS)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have part of a GNU-make makefile (gcc v4.1.2) that is not working as
part of my makefile looks like this ... ifdef vis flg += -framework GLUT
Part of an app I am working on includes a log file viewer, with
Part of my code goes like this: while(1){ my $winmm = new Win32::MediaPlayer; $winmm->load('1.mp3');
I am trying to automatically set the version in a makefile from the CVS
I'm working on this very simple part of code, but somehow the build error
i came across following shell script as part of makefile in u-boot. what it
Part of my makefile for my C++ project uses the diff command to compare
This is the install part of my Makefile: install: for e in $(EXEC); do
I want du extend my makefile.am with an option like this: This is the

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.