This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

(CodeSourcery) gcc link errors for hello world?

Other Parts Discussed in Thread: AM1707

As usual, I must be missing something totally basic here...

#include "stdio.h"
int main()
{
    printf("hello world\n");
    return 0;
}

Link errors say the following functions are not found:

  • _close
  • _fstat
  • _isatty
  • _lseek
  • _read
  • _sbrk
  • _write


Notes

  1. The ultimate goal is to compile StarterWare's usb_bulk_dev example (not supported by CCS CGT?), so the target platform is ARM EABI (arm-none-eabi-gcc)
  2. Linking with the flags "-lc -lgcc -lg" doesn't fix the link errors
  3. CodeSourcery's libc.pdf (Chapter 12) says to write your own stub functions?  Is there no easier way?
  4. Is (3) really how StarterWare does it? But then why are sbrk, etc. nowhere to be found in the source code?
  5. Or, do gcc-compiled StarterWare programs not support printf at all??
  • Chen,

                In embedded environvment we need to define the printf function, Since the definition will change across platforms, the compiler library cant provide printf. In StarterWare we defined UARTPuts() which will print on the serial port.

             So just comment the printf function call, you should be able to link it.

    Regards

    Baskaran

  • Thank you, Baskaran!

    More questions to close up loose ends:

    6. printf is available with CCS/CGT/TMS470; is this via ccs/tools/compiler/tms470/lib/rts*.lib?

    7. Is it at all possible to compile the code in rtssrc.zip with gcc, or maybe a "cross-compile" with tms470 to generate a library that can be linked using gcc?

    Note this is all for use with the Spectrum Digital AM1707 EVM board.

    -Jonathan

  • 6. I am not sure about this. May be the tools team (CCS) can give more info. if you are still interested in this please post a query in "code composer studio" forum.

    7. i dont think code compiled with different tool chains can be linked and executed successfully on target.