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,033
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
    The Real Jdbye @ The Real Jdbye: @Xdqwerty :creep: +1