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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:54:15+00:00 2026-05-26T11:54:15+00:00

Using the following as an example makefile: CC=g++ CFLAGS=-c -Wall LDFLAGS=-lfoobar SOURCES=main.cpp foo.cpp bar.cpp

  • 0

Using the following as an example makefile:

CC=g++
CFLAGS=-c -Wall
LDFLAGS=-lfoobar
SOURCES=main.cpp foo.cpp bar.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello

all: $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -o $@

$(OBJECTS): $(CC) $(CFLAGS) $< -o $@

$< always expands to nothing.

I’ve tried changing it to the following:

CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp foo.cpp bar.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello

all: $(OBJECTS) # or main.o foo.o bar.cpp $(CC) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o: $(CC) $(CFLAGS) $< -o $@

This tells me that there’s no rule for main.o

Am I missing something here? I see a lot of make files using these syntaxes and/or variables and dependencies.

  • 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-26T11:54:16+00:00Added an answer on May 26, 2026 at 11:54 am

    Try this:

    CXX=g++
    CXXFLAGS=-c -Wall
    LDFLAGS=
    SOURCES=main.cpp foo.cpp bar.cpp
    OBJECTS=$(SOURCES:.cpp=.o)
    EXECUTABLE=hello
    
    all: $(EXECUTABLE)
    
    $(EXECUTABLE): $(OBJECTS)  # or main.o foo.o bar.cpp
        $(CXX) -o $@ $(LDFLAGS) $(OBJECTS) $(LIBS)
    

    The rule to build each object file is built-in anyway, so there is no need to define it.

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

Sidebar

Related Questions

I'm trying to access $a using the following example: df<-data.frame(a=c(x,x,y,y),b=c(1,2,3,4)) > df a b
Given the following example (using JUnit with Hamcrest matchers): Map<String, Class<? extends Serializable>> expected
I was trying the following example, but with external URLs: Using WebViews The example
I have tried using the obvious method as outlined in the following example but
I am using the following html page: <html> <head> <title>AJAX Example</title> <meta http-equiv=Content-Type content=text/html;
Please forgive the verbosity of the following code example. Using Delphi 2009, I created
For example, if I'm doing some form input validation and I'm using the following
I'm following the racetrack example from Jason Rudolph's book at InfoQ , using grails-1.2.1.
as example, I've the following SQL query ( using Access 2007 ) SELECT ID,
Using the following example I can get a basic web server running but my

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.