Homebrew Problem with including math.h in a homebrew project

RGT

New Member
OP
Newbie
Joined
Apr 19, 2022
Messages
2
Trophies
0
Age
24
Location
Virginia
XP
30
Country
United States
I'm writing a homebrew project in C, and including math.h just doesn't work for me. I have "#include <math.h>" in there, but when I try to use a function from it like cos() or sin() I get an error while trying to build it that looks like this:
d:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/11.1.0/../../../../arm-none-eabi/bin/ld.exe: C:/Users/rgt/Documents/C_Language/NDS_Project/source/main.c:84: undefined reference to `sin'
collect2.exe: error: ld returned 1 exit status
This is the line mentioned in the above.
double Y_Location = radius * sin(Convert);
Does anyone know what could be wrong? I have no idea how to fix this and get math.h working in my project.
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,035
Country
United States
add -lm argument when you run the code
If you are using the standard devkitpro makefile then add this to LIBS
Makefile:
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS    :=    -lfat -lnds9 -lm
 
  • Like
Reactions: RGT

RGT

New Member
OP
Newbie
Joined
Apr 19, 2022
Messages
2
Trophies
0
Age
24
Location
Virginia
XP
30
Country
United States
If you are using the standard devkitpro makefile then add this to LIBS
Makefile:
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS    :=    -lfat -lnds9 -lm
Thanks! This fixed the problem I was having.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BakerMan
    I rather enjoy a life of taking it easy. I haven't reached that life yet though.
  • BigOnYa
  • Veho @ Veho:
    Ah, yes, portrait mode, surely the best way to film a row of people. If only there were some way to fit a wider shot, at the expense of height... if only...
    +1
  • K3Nv2 @ K3Nv2:
    4k portrait mode?
    +1
  • BigOnYa @ BigOnYa:
    Diddy - "I never touched her, that bitch is crazy." Video is released. Diddy - " Ok I did it, i am remorseful for my actions during my darkest times." Lol
  • SylverReZ @ SylverReZ:
    @BigOnYa, Glad that the Diddler got caught once again.
    +1
  • K3Nv2 @ K3Nv2:
    Iran ran out of options
  • K3Nv2 @ K3Nv2:
    Thought I saw my ex on that new kingdom of the Apes poster
  • BigOnYa @ BigOnYa:
    I thought I saw a puttie snatch...
  • BigOnYa @ BigOnYa:
    I'm so pumped, NCAA football video game is back after a 10 year hiatus, coming to SeriesS/X, PS5 in July.
  • BigOnYa @ BigOnYa:
    Wish they would let us play the NCAA football 14 on newer xbox, its one of the only games I love and own on disc still, that is not back compatible, bs.
  • AdenTheThird @ AdenTheThird:
    @BigOnYa My dad recently bought a spare Series X off of me, got game pass, and saw Madden '24 on Game Pass, decided to try it out.

    ...He was a bit taken aback by the 60GB download size. Poor guy's still living in the 90s!
    +1
  • SylverReZ @ SylverReZ:
    @AdenTheThird, Bro's still in the PS2 age.
  • K3Nv2 @ K3Nv2:
    Lol charging your dad's classic unless he's the type that doesn't like taking things like that
  • AdenTheThird @ AdenTheThird:
    @K3Nv2 He was looking into consoles for his house anyway (for my younger siblings and himself) and I had a spare XSX and Switch I ended up selling him at pretty steep cuts. I would just give them to him, but I did buy them with the intent to sell them... and college is super expensive.
  • BigOnYa @ BigOnYa:
    A little yeah...
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, [insert wut here]
    +1
  • BigOnYa @ BigOnYa:
    I'm a little hi, but bout to fix that.
    +1
  • BigOnYa @ BigOnYa:
    Now I'm low, i was upstairs in my wifeys kitchen, now I'm downstairs in my dungeon.(My basement)
  • BakerMan @ BakerMan:
    do you mind? i snuck in with amiibo and jars, and am trying to do my thing brony style
  • BakerMan @ BakerMan:
    have you ever regretted saying something immediately after saying it?
  • BakerMan @ BakerMan:
    nah what i was doing was trying to cure my ever-so-apparent crabs
    BakerMan @ BakerMan: nah what i was doing was trying to cure my ever-so-apparent crabs