libdragon
libdragon copied to clipboard
Linking to the math library
I'm still getting my head around makefiles and linkers, but I ran into a problem using <math.h>
functions.
Because I didn't know what I was doing with the makefile, I adapted mine from one of the examples which contained this line.
LINK_FLAGS = -L$(ROOTDIR)/mips64-elf/lib -ldragon -lc -lm -ldragonsys -Tn64ld.x
Everything worked fine for a long time until I tried to use the pow
function and I got this build error (repeated five times)
[...]/n64inst/mips64-elf/lib/libm.a(lib_a-w_pow.o): In function 'pow': (.text+0x318): undefined reference to '__errno'
I swapped -lc
and -lm
in that LINK_FLAGS line and it now builds, so this might be something libdragon needs to change as well. Or there was a better solution and I've shot myself in the foot for something down the line.
I think it is safe to swap all of them.
Since everything is static libraries, I surround the libs with --start-group and --end-group.
@clbr Yeah, it seems to be the correct solution.
We didn’t take any action yet, if it is ok with @joeldipops we can close it.
It's not a problem for me any more so I don't mind if it's closed.
Let's wait until we implement --start-group and --end-group into the makefiles.
I think we can close it. math.h works perfectly with through the n64.mk build system. Before n64.mk there wasn't really a standard solutions, so people will have to fix their own makefile for this (or switch to n64.mk). There's not really much we can do about that in libdragon itself.