using <iostream.h> with ARM C++ Projects with Atmel studio 6.1

Simple answer as of now : In a straight forward way no.

But you could try.

To include iostream.h , you have to do the following

1. From project -> properties -> toolchain -> ARM/GNU c++ Compiler ->Directories , include the following directory

C:\Program Files (x86)\Atmel\Atmel Toolchain\ARM GCC\Native\<some version>\arm-gnu-toolchain\arm-none-eabi\include\c++\<some version> (Note that the base path c:\Program Files (x86)……..\ARM GCC might change based on the installation location)

Then, from code add

#include <iostream>

Now compile your code .

You should get the following errors.

Error 5 undefined reference to `_exit’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/stdlib/abort.c

Error 6 undefined reference to `_fstat’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/fstatr.c

Error 7 undefined reference to `_open’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/openr.c

Error 8 undefined reference to `_sbrk’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/sbrkr.c

Error 9 undefined reference to `_kill’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/signalr.c

Error 10 undefined reference to `_getpid’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/signalr.c

Error 11 undefined reference to `_write’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/writer.c

Error 12 undefined reference to `_close’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/closer.c

Error 13 undefined reference to `_isatty’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/isattyr.c

Error 14 undefined reference to `_lseek’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/lseekr.c

Error 15 undefined reference to `_read’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/readr.c

The problem is you need to add the implementation of “syscalls”. When using cout objects (as others objects or functions), the c++ runtime call low level functions called “syscalls”, these functions do architecture specific task. Think this: if you have 2 boards, one using a text lcd display and the other with graphical display , what should cout do, is not the same for each one. Syscalls port hight level functions to work with diferent hardware.

To know how you can write this functions, read the “newlib manual”, chapter 12 (syscalls). These implementation are not available as part of the toolchain distributed by atmel, as of now. I will check if some of the ASF projects include these files, by any chance ?

Update : For SAM3 series devices a sample syscall implementation is available in Atmel ASF example application MXT143E XPLAINED CALC DEMO1. using that fixed most of the errors and now i am left with these three errors.

Error 1 undefined reference to `_open’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/openr.c 59
Error 3 undefined reference to `_read’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/readr.c 58
Error 2 undefined reference to `_write’ /usr/local/avr32studio/hudson/workspace/arm-gnu-toolchain/.build/src/newlib-1.20.0/newlib/libc/reent/writer.c 58

Note that the implementations carries dummy code, so you have to implement them on your own, they are just useful as a template. 🙂

Advertisements