211
Calculator C / Linking static libraries on the TI-Nspire
« on: January 25, 2012, 05:17:38 pm »
I'm porting SDL for the TI-Nspire and ran into some issues while trying to link the resulting static library. I (or rather, the Makefile) first compiled all the SDL source files into objects:
nspire-gcc -Iinclude -nostdlib -lgcc -c in.c -o out.o
It all compiles well, and then I put those objects through ar and ranlib to create a nice libSDL.a. Now when I tried to link that library with some very basic code (just in order to test at least some function is recognized):
Using:
nspire-gcc test.c libSDL.a -Iinclude -lc -lgcc
GCC complains:
If I do not link it with libc/newlib (which would actually be better as far as I can see), it would complain about undefined references to memset(). (something warned about in the GCC man pages)
If any of you know how to deal with this issue, it would help me quite a lot; I could start testing some real code.
Edit:
This is the output when compiling without newlib (i.e., -nostdlib instead of -lc):
nspire-gcc -Iinclude -nostdlib -lgcc -c in.c -o out.o
It all compiles well, and then I put those objects through ar and ranlib to create a nice libSDL.a. Now when I tried to link that library with some very basic code (just in order to test at least some function is recognized):
Code: [Select]
#include "SDL.h"
int main(void) {
SDL_Init(SDL_INIT_VIDEO);
return 0;
}
Using:
nspire-gcc test.c libSDL.a -Iinclude -lc -lgcc
GCC complains:
Code: [Select]
$ nspire-gcc test.c libSDL.a -Iinclude -lc -lgcc
C:\Users\Hoffa\AppData\Local\Temp\ccSJ5EA5.o: In function `exit':
sdl.c:(.text+0x220): undefined reference to `__crt0_savedsp'
sdl.c:(.text+0x224): undefined reference to `__crt0exit'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib\libc.a(lib_a-exit.o): In function `exit':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.19.0/newlib/libc/stdlib/exit.c:65: undefined reference to `_exit'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib\libc.a(lib_a-abort.o): In function `abort':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.19.0/newlib/libc/stdlib/abort.c:63: undefined reference to `_exit'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib\libc.a(lib_a-signalr.o): In function `_kill_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.19.0/newlib/libc/reent/signalr.c:61: undefined reference to `_kill'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib\libc.a(lib_a-signalr.o): In function `_getpid_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.19.0/newlib/libc/reent/signalr.c:96: undefined reference to `_getpid'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.19.0/newlib/libc/reent/sbrkr.c:60: undefined reference to `_sbrk'
collect2: ld returned 1 exit status
If I do not link it with libc/newlib (which would actually be better as far as I can see), it would complain about undefined references to memset(). (something warned about in the GCC man pages)
If any of you know how to deal with this issue, it would help me quite a lot; I could start testing some real code.
Edit:
This is the output when compiling without newlib (i.e., -nostdlib instead of -lc):
Code: [Select]
$ nspire-gcc test.c libSDL.a -Iinclude -nostdlib -lgcc
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol _start; defaulting to 00008000
C:\Users\Hoffa\AppData\Local\Temp\ccqMjuGx.o: In function `exit':
sdl.c:(.text+0x220): undefined reference to `__crt0_savedsp'
sdl.c:(.text+0x224): undefined reference to `__crt0exit'
libSDL.a(SDL_cursor.o): In function `SDL_MouseRect':
SDL_cursor.c:(.text+0x164): undefined reference to `memcpy'
libSDL.a(SDL_keyboard.o): In function `SDL_PrivateKeyboard':
SDL_keyboard.c:(.text+0x390): undefined reference to `memcpy'
libSDL.a(SDL_surface.o): In function `SDL_GetClipRect':
SDL_surface.c:(.text+0x34c): undefined reference to `memcpy'
libSDL.a(SDL_surface.o): In function `SDL_LowerBlit':
SDL_surface.c:(.text+0x3e8): undefined reference to `memcpy'
SDL_surface.c:(.text+0x424): undefined reference to `memcpy'
libSDL.a(SDL_surface.o):SDL_surface.c:(.text+0x838): more undefined references to `memcpy' follow
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(unwind-arm.o): In function `unwind_phase2':
C:\msys\1.0\home\yagarto\gcc-build\arm-none-eabi\libgcc/../../../gcc-4.6.2/libgcc/../gcc/config/arm/unwind-arm.c:698: undefined reference to `abort'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(unwind-arm.o): In function `__gnu_Unwind_Resume':
C:\msys\1.0\home\yagarto\gcc-build\arm-none-eabi\libgcc/../../../gcc-4.6.2/libgcc/../gcc/config/arm/unwind-arm.c:885: undefined reference to `abort'
C:\msys\1.0\home\yagarto\gcc-build\arm-none-eabi\libgcc/../../../gcc-4.6.2/libgcc/../gcc/config/arm/unwind-arm.c:903: undefined reference to `abort'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(pr-support.o): In function `_Unwind_GetDataRelBase':
C:\msys\1.0\home\yagarto\gcc-build\arm-none-eabi\libgcc/../../../gcc-4.6.2/libgcc/../gcc/config/arm/pr-support.c:394: undefined reference to `abort'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(pr-support.o): In function `_Unwind_GetTextRelBase':
C:\msys\1.0\home\yagarto\gcc-build\arm-none-eabi\libgcc/../../../gcc-4.6.2/libgcc/../gcc/config/arm/pr-support.c:400: undefined reference to `abort'
collect2: ld returned 1 exit status