gcclinker-errorsrtems

GCC - Linking is unsuccessful


and sorry for my not really good english. I'll try my best :)

I am trying to compile a addin for my Casio graphic calculator in C. This works without problems when using the official SDK. Because it is only available for Windows, I want to use gcc.

So I got sh-rtems-gcc and it's binutils from macports and tried to compile my program according to this instructions. I copy-pasted the described addin.ld and crt0.s and placed my main.c and libfxsys.a (from the same guys as the instructions mentioned above) in the same directory. The sub-dir include contains fxsys' headers. I verified the presence of all the functions of the library in the .a file with nm.

When using this command for compilation:

sh-rtems-gcc-4.2.3 -m3 -mb -nostdlib -I./include -c crt0.s main.c

Everything works fine. But then im trying to link:

sh-rtems-gcc-4.2.3 -m3 -mb -nostdlib -L. -o myaddin.elf -Taddin.ld crt0.o main.o -lfxsys

and get the following error:

main.o: In function `__main':
main.c:(.text+0x248): undefined reference to `_Bdisp_AllClr_VRAM'
...     
... (--- cut 16 other errors in the same format ---)
...
main.c:(.text+0x360): undefined reference to `_Sleep'
./libfxsys.a(locate.o): In function `_locate':
locate.c:(.text+0x28): undefined reference to `_locate_OS'
collect2: ld gab 1 als Ende-Status zurück

All the missing symbols are in the libfxsys.a. I have verified this with nm.

I have already played with the positions of the library in the command, as this is often mentioned as a source of failure in other posts found in google, but without success. I also tried adding and removing the -lgcc option that is used in the above mentioned instructions, without success.

My Host-Machine is a Intel Mac, OS X 10.6

Because I have no idea how to solve this problem, and get to compile my program, I have to ask: What am I doing wrong? How can I compile my program without using the SDK?

Thanks in advance, xythobuz

Edit:

I have also tried linking with:

sh-rtems-ld -EB -L. -o myaddin.elf -Taddin.ld crt0.o --start-group main.o libfxsys.a --end-group

But it produces the same output as above.


Solution

  • I can't say the exact problem, but would investigate like this:

    1. Find the library that contains the missing symbols. Use nm to see symbol names
    2. Once you know which library contains the symbols make sure you're linking to it, and in the correct order. Try using recursive symbol resolution options -( -) with your linker.