Homebrew Problem with including math.h in a homebrew project

  • Thread starter Thread starter RGT
  • Start date Start date
  • Views Views 1,331
  • Replies Replies 4

RGT

New Member
Newbie
Joined
Apr 19, 2022
Messages
2
Reaction score
0
Trophies
0
Age
26
Location
Virginia
XP
50
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.
 
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
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