This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

C++ eclipse compilation

Hi,

I tried to compile my own program with eclipse and GCC with c/c++. I followed this tutorial : TUTORIAL

I have some problems :

  • First : i have problem with SEGGER RTT lib compilation

    SEGGER_RTT_Syscalls_GCC.c:63:21: warning: its scope is only this definition or declaration, which is probably not what you want

    SEGGER_RTT_Syscalls_GCC.c:98:21: warning: 'struct _reent' declared inside parameter list int _write_r(struct _reent *r, int file, char *ptr, int len) { ^

    SEGGER_RTT_Syscalls_GCC.c:98:5: error: conflicting types for '_write_r' int _write_r(struct _reent *r, int file, char *ptr, int len) { ^

    SEGGER_RTT_Syscalls_GCC.c:63:5: note: previous declaration of '_write_r' was here int _write_r(struct _reent *r, int file, char *ptr, int len); ^

    make: *** [src/Segger_RTT/SEGGER_RTT_Syscalls_GCC.o]

et le contenu du fichier syscalls :

#include "SEGGER_RTT.h"


int _write(int file, char *ptr, int len);
int _write_r(struct _reent *r, int file, char *ptr, int len);

int _write(int file, char *ptr, int len) {
  (void) file;  /* Not used, avoid warning */
  SEGGER_RTT_Write(0, ptr, len);
  return len;
}

int _write_r(struct _reent *r, int file, char *ptr, int len) {
  (void) file;  /* Not used, avoid warning */
  (void) r;  /* Not used, avoid warning */
  SEGGER_RTT_Write(0, ptr, len);
  return len;
}
  • Second : i have problem with memory and standard libraries. (like iostream)

when i use standard lib iostream:

c:/gnutoolsarmembedded/5.42016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: test.elf section .text' will not fit in regionFLASH'

c:/gnutoolsarmembedded/5.42016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 156012 bytes

I saw on google, that is a memory space problem. My .hex is too big.

If someone had same problem or solution.

Regards,

  • Check this post at the SEGGER forum: Conflicting types in SEGGER_RTT_Syscalls_GCC.c. There seems to be a signedness probleme in the library. SEGGER should answer to this.

    For the second problem, yes, adding standard libraries can give you a huge penalty on memory usage. It is quite common to not use them and implement simpler libraries that matches the requirements for the product, that is needed features and available memory.

    Did you do try compiling with optimizations? Could be worth trying. But in general I think iostream is an overkill.

  • What string operations do you need? Could you do what you want with string.h (C library) and wrap it into C++?

  • I found an other post : post and i downloaded the latest Jlink code source. There is the same code. There are the sames errors.

    I dont understand why they tried to "overload" the initial function but it doesn't work.

  • Hi,

    RTT files are included in the latest SDK (11.0.0), under (sdk folder)/external/segger_rtt. Some of the SDK examples uses RTT, in particular for logging (nrf_log library). If the RTT files are included in the SDK you are using then I suggest you stick to them rather than fetching a potentially different version from segger.

    When that is said, I do have some vague memories of getting similar errors myself. I do not remember what I did to fix it, but if you enable RTT logging for an SDK example and get that to work you should at least have some idea what a working setup looks like.

    Regarding C++ libraries (or rather, their size) microcontrollers in general have limited program memory and are traditionally programmed in C. This means most lightwight and μc libraries are written in C. Also C++ libraries have not been subject to the same size limitations as have C libraries. Add to this that some string manipulations are complex operations, and you will see why string libraries are so large. I am sure someone would suggest a library if you state what operations you need.

    Regards, Terje

  • I tried with sample and keil, the sysCall files isnt the same, the function inside too. I want to use it with eclipse so i use sysCallgcc file.

Related