Omnimaga

Calculator Community => Casio Calculators => Topic started by: blue_bear_94 on March 04, 2013, 05:37:33 pm

Title: Linker error - Can't use stdlib.h or math.h functions!
Post by: blue_bear_94 on March 04, 2013, 05:37:33 pm
When I try to use stdlib.h functions (regardless of whether I #include <stdlib.h> or not), I get linker errors like these:
Code: [Select]
bullets.o: In function '_freeList':
bullets.c:(.text+0x384): undefined reference to '_free'
bullets.o: In function '_createNode':
bullets.c:(.text+0x39c): undefined reference to '_malloc'

Same for math.h functions. I also have the fxcglib installed. Are these functions not implemented yet?

Thanks in advance!
Title: Re: Linker error - Can't use stdlib.h or math.h functions!
Post by: Juju on March 04, 2013, 11:46:44 pm
How did you compiled your program? What's the gcc command line used to compile this?
Title: Re: Linker error - Can't use stdlib.h or math.h functions!
Post by: AngelFish on March 05, 2013, 12:38:49 am
Both malloc and free are implemented in <stdlib.h>, but try including the raw library in your build folder and using
Code: [Select]
#include "stdlib.h" to see if that fixes the problem. Otherwise, you're not calling the linker properly.
Title: Re: Linker error - Can't use stdlib.h or math.h functions!
Post by: blue_bear_94 on March 05, 2013, 03:51:25 pm
How did you compiled your program? What's the gcc command line used to compile this?
Code: [Select]
> sh3eb-elf-gcc bullets.o posnmath.o starvak2.o xpo.o -mb -m4a-nofpu -mhitachi -nostdlib -TC:/Users/Kook/Desktop/TISTUFF/PrizmSDK-0.3/common/prizm.ld -Wl,-static -Wl,-gc-sections -LC:/Users/Kook/Desktop/TISTUFF/PrizmSDK-0.3/lib -lfxcg -lgcc -o C:/Users/Kook/Desktop/TISTUFF/PrizmSDK-0.3/projects/starvak2/starvak2.bin For some reason it's ignoring the standard libs. However, I can't change this because the make.bat file calls make.exe in the /bin folder.
Both malloc and free are implemented in <stdlib.h>, but try including the raw library in your build folder and using
Code: [Select]
#include "stdlib.h" to see if that fixes the problem. Otherwise, you're not calling the linker properly.
Will try!


Edit: tried it, and got the same error.
Title: Re: Linker error - Can't use stdlib.h or math.h functions!
Post by: Juju on March 05, 2013, 04:25:35 pm
Try -lc in the command line?
Title: Re: Linker error - Can't use stdlib.h or math.h functions!
Post by: blue_bear_94 on March 05, 2013, 04:43:34 pm
Well, I use the make.bat file, which calls make.exe, so using -lc here doesn't work.
Title: Re: Linker error - Can't use stdlib.h or math.h functions!
Post by: blue_bear_94 on March 07, 2013, 05:30:48 pm
Deleting the -nostdlib flag in /common/prizm_rules and calling make.bat again resulted in these errors:
Code: [Select]
...: In function 'stack_k':
(.text+0x50): undefined reference to '_stack'
...
_end_k; end
_main_k; __setup_argv_and_call_main
_atexit_k; _atexit
And it goes on and on.