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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:47:46+00:00 2026-06-06T21:47:46+00:00

When I try to run the following make file (updated with suggestions below): #

  • 0

When I try to run the following make file (updated with suggestions below):

# Build Directories
src_dir=src
obj_dir=obj
bin_dir=bin

cc=cl
cc_flags=

configs = dbg rel

# create the directory for the current target.
dir_guard=@mkdir -p $(@D)

# source files
src = MainTest.cpp

define build_template = 
# object files - replace .cpp on source files with .o and add the temp directory prefix
obj_$(1) = $$(addprefix $$(obj_dir)/$(1)/, $$(addsuffix .obj, $$(basename $$(src))))

testVar = "wooo"

# build TwoDee.exe from all of the object files.
$$(bin_dir)/$(1)/MainTest.exe : $$(obj_$(1))
    $$(dir_guard)
    $$(cc) -out:$$@ $$(obj_$(1)) -link

# build all of the object files in the temp directory from their corresponding cpp files.
$$(obj): $$(obj_dir)/$(1)/%.obj : $$(src_dir)/%.cpp
    $$(dir_guard)
    $$(cc) $$(cc_flags) -Fo$$(obj_dir)/$$(1) -c $$<
endef

$(foreach cfg_dir,$(configs),$(eval $(call build_template,$(cfg_dir))))

release: $(bin_dir)/rel/MainTest.exe

debug: cc_flags += -Yd -ZI
debug: $(bin_dir)/dbg/MainTest.exe

$(warning testVar $(testVar))

All I get is:

$ make
Makefile:41: testVar
make: *** No rule to make target `bin/rel/MainTest.exe', needed by `release'.  Stop.

You can see from the output that the testVar variable is never set. I made these changes based on my last question: Why doesn't my makefile target-specific variable work?

  • 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-06T21:47:48+00:00Added an answer on June 6, 2026 at 9:47 pm

    There are some spaces which confuse Make. Try this:

    $(foreach cfg_dir,$(configs),$(eval $(call build_template,$(cfg_dir))))
    

    Also make sure that you specify the right objects to link:

        $$(cc) -out:$$@ $$(obj_$(1)) -link
    

    And as @Beta pointed out in the comments below, the = in the template definition syntax requires GNU make 3.82 or later. So better omit it from the line:

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

Sidebar

Related Questions

I try to run the following raw query in android, it seems not work
I try to run the following code: public void Init(Url rootUrl) { var web
When I try to run the following SQL snippet inside a cursor loop, set
When I try to run the following code from the REPL (playing with dynamic
When I try to run the following, I get an error back from ActiveRecord
I try to run jsf application in myeclipse using jboss web server and following
When i try and run at server i am getting the following severe error:
I get the following error when I try to run sample example of Google
When I try to run a routine I get the following error: Error Code:
I'm getting the following error when I try to run a simple Java JDBC

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.