Linker errors in _flshbuf and malloc

Hello everybody,

maybe this is a stupid question (in which case I apologize). I got two linker errors:

Phase OptLinker starting

License expires in 10 days

L2310 (E) Undefined external symbol "_write" referenced in "_flshbuf"

L2310 (E) Undefined external symbol "_sbrk" referenced in "malloc"

Phase OptLinker finished

I have seen several posts in this and other forums describing this behaviour, but did not find a working solution. I tried to change the Standard Library Settings in the toolchain, without any success. After searching for the sbrk symbol I found it at <HEW>\System\Pg\Renesas\SH\Sh_9_0\Generate\sbrk\sbrk.c. I do not know what this Generate folder is for, but I guess it is part of the files of which the Standard Library is built.

Any idea how to solve this?

C/C++ compiler package for SuperH RISC engine family V.9.04 Release 01          (10-8-2012 15:03:03)

High-performance Embedded Workshop Upgrade 4.09.01          (10-8-2012 16:33:21)

SH-4A E10A-USB Emulator V.3.04.00          (10-8-2012 16:43:15)

SH-4A E10A-USB Emulator V.3.04.00          (10-8-2012 16:44:15)

E10A-USB Emulator Common Module V.4.09.01          (10-8-2012 16:54:26)

SH-2A E10A-USB Emulator V.3.05.00          (10-8-2012 16:59:42)

  • You try to use printf() but did not select the option "Use I/O Library" during project set up.

    So you are missing the low level routines for it. You have to add following files to your project:

    lowsrc.c and lowsrc.h

    lowlvl.src

    sbrk.c and sbrk.h

    or you simply generate a new project and mark "Use I/O Library" during set up.

    You should enable _INIT_IOLIB() in resetprg.c

    If you don't use the simulated IO you have to modify charput() and charget() in lowlvl.src to suit your needs.

    Rgds

    Frank

  • Thanks, Frank! happy

    Is there any chance to select the "Use I/O Library" option after the project already has been set up? I would like to avoid to reconfigure everything, and copying the mentioned files into my project seems somehow dirty to me (or is it the "natural" way?)...

    Does this option somehow correspond to the "Toolchain Settings>Standard Library>Object>Simple I/O function"?

    Anyway, thanks for the fast answer!!!

  • Sorry, no other way. I think the best way is to create a new project with the option set, and then copy the files to your project.

    The "Simple I/O functio" has nothing to do with these files and the "Use I/O Library" option. This simple I/O function option only limits the functionality of printf() and thus reduces the printf size considerably.

    Rgds

    Frank

  • Hello, I have the same exact problem in a project developed for H8s/tiny 20215F CPU, as soon as I try to insert a malloc() anywhere in any source file in my project, the same exact error message appears.... the difference is that I NEVER use printf in my project, it's a firmware project that only uses direct hardware management (I/O ports, UART, I2c)
    Anyway I tried to #include lowsrc in my project but I can't find the files, it seems they are not supplied with the H8s packege for the HEW...

    any help please?

    regards