This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Undefined reference to xxx with arm-elf-gcc


Hello Christian,

Your problem here seems to be missing refs to libc and libgcc.
Even if you included the -lgcc and -lc switchs on your cmd line, please keep in mind that
ld only uses the -l switch to solve refs once. It does not "backward" search, that is
taking again the -l switches and re-searching for symbs in these libs.

The solution is simply to put everything at the very end of the cmd line eg.
-L_path_of_libs -lc -lgcc. I also recommend you to link with gcc instead of ld since it
handles all that.

This may not sound very clear. Simply putting one of your error messages in google will
give you good references/explanations to that.

Hopes that helps

Cheers,

Vincent

nac@hta-bi.bfh.ch wrote:
> 
> I am having some problems compiling for an arm with arm-elf-gcc.
> The problem apears when linking of the type undefined reference to ...
> Here is a part of the error messeges. I already tried -lgcc and -lc but
> that dous not work. Christian
> 
> arm-elf-gcc  -g -c -o crt0.o crt0.S
> arm-elf-gcc  -g -c -o MyRSA.o MyRSA.c -I /usr/include
> arm-elf-gcc  -g -c -o mpi.o mpi.c -I /usr/include
> arm-elf-ld crt0.o MyRSA.o mpi.o -Tarmebs_ldscript -o rsa.exe -lc -L
> /usr/lib
> mpi.o: In function `mp_init_size':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:282: undefined reference to `__eprintf'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:282: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:284: undefined reference to `calloc'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:284: relocation truncated to fit:
> R_ARM_PC24 calloc
> 
> mpi.o: In function `mp_init_copy':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:309: undefined reference to `__eprintf'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:309: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:314: undefined reference to `calloc'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:314: relocation truncated to fit:
> R_ARM_PC24 calloc
> 
> mpi.o: In function `mp_copy':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:340: undefined reference to `__eprintf'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:340: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:360: undefined reference to `calloc'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:360: relocation truncated to fit:
> R_ARM_PC24 calloc
> 
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:369: undefined reference to `free'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:369: relocation truncated to fit:
> R_ARM_PC24 free
> 
> mpi.o: In function `mp_exch':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:400: undefined reference to `__eprintf'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:400: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> mpi.o: In function `mp_clear':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:431: undefined reference to `free'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:431: relocation truncated to fit:
> R_ARM_PC24 free
> 
> mpi.o: In function `mp_sub':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:968: undefined reference to `__eprintf'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:968: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> mpi.o: In function `mp_div':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:1149: undefined reference to `__eprintf'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:1149: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> mpi.o: In function `mp_mod':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:1358: undefined reference to `__eprintf'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:1358: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> mpi.o: In function `mp_exptmod':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:1639: undefined reference to `__eprintf'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:1639: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> mpi.o: In function `mp_cmp':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:1811: undefined reference to `__eprintf'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:1811: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> mpi.o:/d/Cod-it/C_ARM/RSA_v5/mpi.c:2469: more undefined references to
> `__eprintf
> ' follow
> mpi.o: In function `mp_read_radix':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:2469: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> mpi.o: In function `mp_toradix':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:2552: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:2553: relocation truncated to fit:
> R_ARM_PC24 __eprintf
> 
> mpi.o: In function `s_mp_grow':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:2664: undefined reference to `__udivsi3'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:2664: relocation truncated to fit:
> R_ARM_PC24 __udivsi3
> 
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:2666: undefined reference to `calloc'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:2666: relocation truncated to fit:
> R_ARM_PC24 calloc
> 
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:2674: undefined reference to `free'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:2674: relocation truncated to fit:
> R_ARM_PC24 free
> 
> mpi.o: In function `s_mp_div_d':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:3242: undefined reference to `__udivsi3'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:3242: relocation truncated to fit:
> R_ARM_PC24 __udivsi3
> 
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:3243: undefined reference to `__umodsi3'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:3243: relocation truncated to fit:
> R_ARM_PC24 __umodsi3
> 
> mpi.o: In function `s_mp_div':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:3642: undefined reference to `__udivsi3'
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:3642: relocation truncated to fit:
> R_ARM_PC24 __udivsi3
> 
> mpi.o: In function `s_mp_tovalue':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:3941: undefined reference to `_ctype_'
> mpi.o: In function `s_mp_todigit':
> /d/Cod-it/C_ARM/RSA_v5/mpi.c:3970: undefined reference to `_ctype_'
> make: *** [rsa.exe] Error 1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]