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

  • Home
  • SEARCH
  • 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 6659417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:01:55+00:00 2026-05-26T02:01:55+00:00

I have been using a makefile that I inherited from the internet for long

  • 0

I have been using a makefile that I inherited from the internet for long enough! It is time that I learn to compile my own projects once and for all. So I’ve read some tutorials and thrown together a mock-up. It doesn’t work, and I am at my wits end now (which is usually when I come to YOU).

As usual, thank you all in advance for being so knowledgeable.

lib.h

#ifndef LIB_H
#define LIB_H

/** returns the integer zero (0), because the 
 * 0 key on my keyboard is broken. 
 * @pre my keyboard is broken 
 * @post nope, still broken
 * @returns 0 */
int zero();

#endif

lib.cpp

#include "lib.h"

int zero() {

  return 0;
}

project.cpp

#include "lib.h"

int main () {

  int i = zero();

  return 0;
}

makefile
(the arrows are tab characters)

project: lib.o project.o
-->g++ lib.o project.o -o project

project.o: project.cpp lib.h
-->g++ -c project.cpp

lib.o: lib.cpp lib.h
-->g++ -c lib.cpp

When, from the command line, I run

$ make

I get the following error:

g++ project.cpp
/tmp/ccWCSqSx.o: In function 'main':
project.cpp:(.text+0x9): undefined reference to 'zero()'
collect2: ld returned 1 exit status
make: *** [project.o] Error 1

This is clearly a case of me having missed some crucial piece of information somewhere along the lines. I’ve googled this a bunch, but most of the results have been people with real problems, and I haven’t been able to learn what’s missing. Looking forward to being tremendously embarrassed by the answer,

Thanks!

  • 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-26T02:01:55+00:00Added an answer on May 26, 2026 at 2:01 am

    The error message gives the command line:

    g++ project.cpp
    

    Note the lack of -c. That’s apparently not in your makefile, in spite of what you think.

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

Sidebar

Related Questions

Some Background I have been using Git for a while now. The projects that
I have been using maven projects in hudson quite successfully for some time. However
I have been using Eclipse as an IDE for a short amount of time
I have been using named branches both as feature branches and long lived branches.
I'm using a Makefile to build an embedded project. I've inherited the project from
We have been using CruiseControl for quite a while with NUnit and NAnt. For
I have been using PHP and JavaScript for building my dad's website. He wants
I have been using Castle MonoRail for the last two years, but in a
We have been using Scrum for around 9 months and it has largely been
I have been using C# for a while now, and going back to C++

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.