Homebrew Problem with including math.h in a homebrew project

RGT

New Member
OP
Newbie
Joined
Apr 19, 2022
Messages
2
Trophies
0
Age
23
Location
Virginia
XP
20
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,033
Trophies
1
XP
2,614
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
23
Location
Virginia
XP
20
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.
 
General chit-chat
Help Users
  • SylverReZ @ SylverReZ:
    Hope they made lots of spaget
  • K3N1 @ K3N1:
    Chill dog
  • SylverReZ @ SylverReZ:
    Chilli dog
  • Skelletonike @ Skelletonike:
    Damn, I'm loving the new zelda.
  • xtremegamer @ xtremegamer:
    loving the new zelda, i started a game, it was so fucking good, so i
    am waiting on my friend to get home so we can start a new one together
  • Skelletonike @ Skelletonike:
    I just dislike that they don't let me choose the voices before the game starts. Happened with botw as well, had to change to japanese and restart.
  • K3N1 @ K3N1:
    But the important question is can you choose gender
  • Skelletonike @ Skelletonike:
    Same way you can choose Gerald's gender.
  • Skelletonike @ Skelletonike:
    *Geralt, damn autocorrect.
  • Psionic Roshambo @ Psionic Roshambo:
    But can he be trans? Lol
  • K3N1 @ K3N1:
    Zelda transforms into link
  • Psionic Roshambo @ Psionic Roshambo:
    Link I'm not the princess your looking for.... *Pulls a crying game*
  • K3N1 @ K3N1:
    *skirt up* it's exactly what I always wanted
  • Skelletonike @ Skelletonike:
    Just scanned all my zelda amiibos, took a while but didn't get anything that cool, did get the lon lon ranch hylian fabrics though.
  • Skelletonike @ Skelletonike:
    It was pretty funny when I scanned wolf link and got a shit load of meat.
  • K3N1 @ K3N1:
    @Skelletonike, btw I ran that custom for mgs4 on the deck I'm amazed it got that far in game
  • K3N1 @ K3N1:
    Plug in*
  • K3N1 @ K3N1:
    Your favorite activity
  • BentlyMods @ BentlyMods:
    My fav actvity is:

    mario-dancing.gif
  • Psionic Roshambo @ Psionic Roshambo:
    Do the Mario lol
  • K3N1 @ K3N1:
    🍑
    K3N1 @ K3N1: 🍑