Topic : Unable to compile C++ project...

Forum : ARM

Original Post
Post Information Post
May 24, 2010 - 10:38pm
Guest

Hello all,

after numerous attempts I'm still not able to compile a C++ project under Ride7 (I'm using Windows XP). I know that C++ isn't officialy supported by the IDE, but in this post:

http://www.stm32circle.com/forum/viewtopic.php?id=433

VincentC gave some indications in order to compile a C++ project under Ride (above all, using libstdc++).
Unfortunately the linker gives me these error messages:

Code:

Building C:\Documents and Settings\.... 
 Running: LD 
 "C:\Programmi\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -
mthumb -Wl,-T -Xlinker "out\FW FAS.elf.ld" -u _start -Wl,-static -Wl,--gc-sections -
nostartfiles -Wl,-Map -Xlinker "lst\FW FAS.map" -Wl,--warn-once  -Wl,-lstdc++ 
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-
none-eabi/lib/thumb2\libc.a(lib_a-abort.o): In function `abort':  
 abort.c:(.text+0x8): undefined reference to `_exit'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-
none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_getpid_r':  
 signalr.c:(.text+0x2): undefined reference to `_getpid'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-
none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_kill_r':  
 signalr.c:(.text+0x1c): undefined reference to `_kill'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-
none-eabi/lib/thumb2\libc.a(lib_a-writer.o): In function `_write_r':  
 writer.c:(.text+0x16): undefined reference to `_write'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-
none-eabi/lib/thumb2\libc.a(lib_a-closer.o): In function `_close_r':  
 closer.c:(.text+0x12): undefined reference to `_close'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-
none-eabi/lib/thumb2\libc.a(lib_a-fstatr.o): In function `_fstat_r':  
 fstatr.c:(.text+0x14): undefined reference to `_fstat'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-
none-eabi/lib/thumb2\libc.a(lib_a-isattyr.o): In function `_isatty_r':  
 isattyr.c:(.text+0x12): undefined reference to `_isatty'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-
none-eabi/lib/thumb2\libc.a(lib_a-lseekr.o): In function `_lseek_r':  
 lseekr.c:(.text+0x16): undefined reference to `_lseek'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-
none-eabi/lib/thumb2\libc.a(lib_a-readr.o): In function `_read_r':  
 readr.c:(.text+0x16): undefined reference to `_read'  
 collect2: ld returned 1 exit status  
  
Build failed

Note the numerous "undefined reference ...".
Anyone can help me?

Replies
Post Information Post
+1
0
-1
May 26, 2010 - 5:39pm
Guest

Hi

The error message listed above might not come from the fact that you are compiling a c++ project.
I suggest you make a trial with a basic project simply defining a class, initializing it and change its value.
This should shows that you did everything to make the use of c++ projects possible.

The error messages in your post are more related to symbols definition mismatch due to te use of a kind of printf or malloc function.
I think adding into your project the sources from C:\Program Files\Raisonance\ride\lib\ARM\std_sbrk
might resolve the problem.

Regards
Matloub

+1
0
-1
May 27, 2010 - 1:58pm
Guest

matloub wrote:
Hi

The error message listed above might not come from the fact that you are compiling a c++ project.
I suggest you make a trial with a basic project simply defining a class, initializing it and change its value.
This should shows that you did everything to make the use of c++ projects possible.

Hi Matloub, thanks for your answer!

Well, I've tried your suggestion to make a very simple cpp project, but the problem seems to be residing in the use of C++.
Suppose we have the following simple class, "Prova", which has a field and a constructor:

Prova.h

class Prova {

    public:
        
        int valore;
    
        Prova(int val);
};

Prova.cpp

#include "Prova.h"

Prova::Prova(int val) {
    this->valore = val;
}

The main is this:

#include "Prova.h"

int main() {
   Prova p1(2);
}

When compiling the above code, the linker gives me this output:


[...]

Building C:\Documents and Settings\....
 Running: LD 
 "C:\Programmi\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker "C:\Documents and Settings\francesco.lettich\Documenti\Progetti\Prosa\ProvaCPP\ProvaCPP.elf.ld" -u _start -Wl,-static -Wl,--gc-sections -nostartfiles -Wl,-Map -Xlinker "C:\Documents and Settings\francesco.lettich\Documenti\Progetti\Prosa\ProvaCPP\ProvaCPP.map"   -lstdc++ 
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-abort.o): In function `abort':  
 abort.c:(.text+0x8): undefined reference to `_exit'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_getpid_r':  
 signalr.c:(.text+0x2): undefined reference to `_getpid'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_kill_r':  
 signalr.c:(.text+0x1c): undefined reference to `_kill'  
 c:/programmi/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':  
 sbrkr.c:(.text+0x12): undefined reference to `_sbrk'  
 collect2: ld returned 1 exit status  
  
Build failed 

An interesting thing is that, if I comment the line contaning the instantiation of the "Prova" object, then everything goes fine!

About your other suggestion regarding std_sbrk:

Quote:
The error messages in your post are more related to symbols definition mismatch due to te use of a kind of printf or malloc function.
I think adding into your project the sources from C:\Program Files\Raisonance\ride\lib\ARM\std_sbrk
might resolve the problem.

Regards
Matloub

This seemed to help a bit. In fact, if I copy the sources of that directory in the directory of my sources, then I have only this error message:


[...]

Building C:\Documents and Settings\...
 Running: LD 
 "C:\Programmi\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker "out\FW FAS.elf.ld" -u _start -Wl,-static -Wl,--gc-sections -nostartfiles -Wl,-Map -Xlinker "lst\FW FAS.map" -Wl,--warn-once  -Wl,-lstdc++ 
 out\write.o: In function `_write':  
 write.c:(.text._write+0xe): undefined reference to `__io_putchar'  
 collect2: ld returned 1 exit status  

Do you have other suggestions?
Thanks :)