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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:40:33+00:00 2026-06-14T15:40:33+00:00

I know this error has been beaten to death, but I cannot seem to

  • 0

I know this error has been beaten to death, but I cannot seem to get it to work. I have linked my makefile below:

all: gensine info cs229towav

encode.o: encode.h encode.c
    gcc -c encode.c

write.o: write.c write.h
    gcc -c write.c

gensine.o: encode.c gensine.h gensine.c helper.c write.c
    gcc -c gensine.c -lm

helper.o: helper.c helper.h
    gcc -c helper.c

read.o: read.h read.c
    gcc -c read.c

info.o:read.c info.h info.c decode.c
    gcc -c info.c

decode.o: decode.c decode.h helper.c
    gcc -c decode.c

cs229towav.o: write.c read.c cs229towav.c cs229towav.h helper.c decode.c encode.c
    gcc -c cs229towav.c -lm

gensine: encode.o gensine.o write.o helper.o
    gcc -o gensine encode.o gensine.o write.o helper.o -lm

info: read.o info.o decode.o helper.o
    gcc read.o info.o decode.o helper.o

cs229towav: write.o read.o cs229towav.o decode.o encode.o helper.o
    gcc -o write.o read.o cs229towav.o decode.o encode.o helper.o -lm

Clean:
    rm -rf *o gensine info cs229towav

When I run a command such as “make gensine” I am returned with the following result:

>cc gensine.c -o gensine
/tmp/ccojm09X.o: In function `encodeCsFormat':
gensine.c:(.text+0x4b1): undefined reference to `sin'
/tmp/ccojm09X.o: In function `encodeWavFormat':
gensine.c:(.text+0xa39): undefined reference to `sin'
collect2: error: ld returned 1 exit status

After reading this is says undefined reference to sin, which is with the math library. Those functions listed are in the “encode.c” file which are included in the “gensine.c” file.

  • 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-14T15:40:35+00:00Added an answer on June 14, 2026 at 3:40 pm

    The command in the makefile:

    gcc -o gensine encode.o gensine.o write.o helper.o -lm
    

    does not match the command you printed at the end:

    cc gensine.c -o gensine
    

    Notice also that there is no -lm

    Note that make knows how to make object files so you don’t need most of the makefile. Try this (remember to indent with TABs):

    .PHONY : all clean
    all = gensine info
    CFLAGS =-Wall
    LIBS = -lm
    
    gensine: encode.o gensine.o write.o helper.o 
           gcc -o $@ $^ $(LIBS)
    
    info: read.o info.o decode.o helper.o
           gcc -o $@ $^ $(LIBS)
    
    cs229towav: write.o read.o cs229towav.o decode.o encode.o helper.o
           gcc -o $@ $^ $(LIBS)
    
    clean:
           rm -rf *.o gensine info cs229towav
    

    Edit:

    Boddie, note that your confusion arose because you thought the makefile was a script – ie. that you were running your script named make when you typed make gensine. In fact make is a command like gcc somewhere else in the filesystem (on Linux etc, type which make to see where it is). The make command expects to find an input file containing build rules called makefile or Makefile in the current directory. If it doesn’t find that file it uses some built-in rules instead – hence the cc gensine.c -o gensine which is nowhere in your makefile. If you want to, you can tell make the name of the makefile (so that it doesn’t use the default names) with the -f switch, as @DanielFischer described in the comments.

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

Sidebar

Related Questions

I know this topic has been beaten into the ground, but I'm really stumped.
I know this has been asked before, but for my circumstance, I can't seem
I know this error has been bitten to death over here, and I read
I know this type of error has been raised many times before, but I
I know this has been addressed before but I have service that returns a
I know this is an error that has been explained at length in numerous
I know this has been asked a million times but I think I need
I know this question has been asked here a few times before. But i
I know this has been asked a few times here. But none of the
I know this question has been asked before and I have seen a plethora

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.