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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:11:43+00:00 2026-05-23T16:11:43+00:00

Alright so this is my current setup for a makefile. There are files which

  • 0

Alright so this is my current setup for a makefile. There are files which are named public01.c, public02.c, etc. I’m trying to make object files for each of them using the public*.o label with a wildcard.

public*.o: public*.c hashtable.h
    $(CC) $(CFLAGS) -c public*.c

public*: public*.o
    $(CC) -o public* public*.o

However, when I try and run the makefile, I get this:

make: *** No rule to make target `public*.c', needed by `public*.o'.  Stop.

I guess it’s treating public*.c as a label and not a wildcard as I’d like. I read about $(wildcard pattern...) function and played around with it, but I didn’t really understand it or got it to 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-05-23T16:11:43+00:00Added an answer on May 23, 2026 at 4:11 pm

    Short answer: that syntax does not work the way you want it to. The correct way to do what you want in GNU make syntax is to use pattern rules:

    public%.o: public%.c hashtable.h
            $(CC) $(CFLAGS) -c $<
    
    public%: public%.o
            $(CC) -o $@ $<
    

    Long answer: This:

    public*.o: public*.c hashtable.h
    

    does not mean what you want it to mean. Assuming you have several file public01.c, etc., and no files public01.o, etc., at the start of your build, that syntax is equivalent to this:

    public*.o: public01.c public02.c public03.c ... hashtable.h
    

    That is, if public01.o, etc., do not exist, then make will use the literal string public*.o as the filename. If some of the .o files do exist, then that syntax is equivalent to this:

    public01.o public02.o ...: public01.c public02.c ... hashtable.h
    

    Seems like what you want right? But that’s a common misunderstanding with make, because in fact that line is exactly the same as this:

    public01.o: public01.c public02.c ... hashtable.h
    public02.o: public01.c public02.c ... hashtable.h
    

    That is — every .o file has a dependency on every .c file! The correct way to do what you want is to use a pattern rule, as shown above.

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

Sidebar

Related Questions

Alright, so I have this bit of code, and when I make the request,
Alright so I'm trying to get this class work: public boolean hasPoint(Point p){ for
Alright, this is my current code snippet: namespace bai = boost::asio::ip; bai::tcp::socket tcp_connect(std::string hostname,
Is it alright to do this? $author = strtolower($_SESSION['valid_username']); I want to enter all
Alright so I have this C++ image capturing class. I was wondering if I
Alright, this one (3a; sample problem with provided answer) has got me scratching my
Alright, I'll preface this with the fact that I'm a GTK and Python newb,
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
Alright, I am going to state up front that this question may be too

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.