Shop OBEX P1 Docs P2 Docs Learn Events
Some Questions about C++ Features — Parallax Forums

Some Questions about C++ Features

ReinhardReinhard Posts: 489
edited 2011-11-17 13:51 in Propeller 1
Hi,

I try the C++ Features, and something works well.

I think with Classes and Instances it is similar to handle like SPIN Objects.

2 Questions remain: errors below I get if I uncomment the parts in the attached source files.

using of Destructor :

/cygdrive/c/DOKUME~1/Reinhard/LOKALE~1/Temp/ccwYPCvm.o: In function `_main':
(.text+0x1c): undefined reference to `___gxx_personality_sj0'
collect2: ld returned 1 exit status

using of new :

/cygdrive/c/DOKUME~1/Reinhard/LOKALE~1/Temp/ccGVPYxQ.o: In function `_main':
(.text+0x1c): undefined reference to `___gxx_personality_sj0'
/cygdrive/c/DOKUME~1/Reinhard/LOKALE~1/Temp/ccGVPYxQ.o: In function `_main':
(.text+0x1d0): undefined reference to `operator new(unsigned int)'
/cygdrive/c/DOKUME~1/Reinhard/LOKALE~1/Temp/ccGVPYxQ.o: In function `.L4':
(.text+0x254): undefined reference to `operator delete(void*)'
collect2: ld returned 1 exit status

Maybe I make some wrong ?

best regards
Reinhard

Comments

  • ersmithersmith Posts: 6,100
    edited 2011-11-15 13:23
    Usually you have to use propeller-elf-g++ to compile C++ code, especially for the final link step -- g++ knows to link the C++ libraries, gcc does not.

    Unfortunately there is currently a build issue in libstdc++, so it wasn't in the initial alpha release. I hope we'll have it working soon.

    Eric
  • ReinhardReinhard Posts: 489
    edited 2011-11-15 13:35
    @ersmith

    Ohh, yes I see

    Thanks for quick response

    D:\myC\propeller_chip\gcc\C++>mk

    D:\myC\propeller_chip\gcc\C++>propeller-elf-g++ -mlmm -o SquareWaveGenerator.o -c SquareWaveGenerator.cpp

    D:\myC\propeller_chip\gcc\C++>pause
    Dr
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2011-11-16 21:31
    Reinhard wrote: »
    /cygdrive/c/DOKUME~1/Reinhard/LOKALE~1/Temp/ccwYPCvm.o: In function `_main':
    (.text+0x1c): undefined reference to `___gxx_personality_sj0'
    collect2: ld returned 1 exit status
    Somewhere, in your source, put "int ___gxx_personality_sj0 = 0;". It's an ugly workaround hack, for now. That symbol is never actually used for anything useful, if you look at the assembly listing output (gcc -S), but it does need to be defined.
    Reinhard wrote: »
    /cygdrive/c/DOKUME~1/Reinhard/LOKALE~1/Temp/ccGVPYxQ.o: In function `_main':
    (.text+0x1c): undefined reference to `___gxx_personality_sj0'
    /cygdrive/c/DOKUME~1/Reinhard/LOKALE~1/Temp/ccGVPYxQ.o: In function `_main':
    (.text+0x1d0): undefined reference to `operator new(unsigned int)'
    /cygdrive/c/DOKUME~1/Reinhard/LOKALE~1/Temp/ccGVPYxQ.o: In function `.L4':
    (.text+0x254): undefined reference to `operator delete(void*)'
    collect2: ld returned 1 exit status
    "new" and "delete" require malloc/free, which I've not seen implemented on any embedded systems. I'd limit my use to statically-defined objects.

    [DISCLAIMER]I've never used propgcc; I've only tried to avoid libstdc++ on small c++ programs on x86.[/DISCLAIMER]
    ersmith wrote: »
    Unfortunately there is currently a build issue in libstdc++, so it wasn't in the initial alpha release. I hope we'll have it working soon.
    ___gxx_personality_sj0 is referenced by C++ programs, even if no libstdc++ features are ever used. If you could include a dummy library that defines that, or define it in the linker script, until libstdc++ works, that would be quite helpful.
  • ersmithersmith Posts: 6,100
    edited 2011-11-17 04:50
    ___gxx_personality_sj0 is referenced by C++ programs, even if no libstdc++ features are ever used. If you could include a dummy library that defines that, or define it in the linker script, until libstdc++ works, that would be quite helpful.

    Thanks for the tips. We have libstdc++ building now, but it is extremely large, so it'd probably be useful to have a dummy libstdc++ that people can choose to link with for minimal C++ programs.

    Eric
  • jazzedjazzed Posts: 11,803
    edited 2011-11-17 07:44
    "new" and "delete" require malloc/free, which I've not seen implemented on any embedded systems. I'd limit my use to statically-defined objects.
    Yes, we expect programmers mainly to use statically defined objects, but we support hardware configurations that may allow using new/delete.

    Welcome to the forums.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2011-11-17 13:51
    jazzed wrote: »
    Welcome to the forums.
    Thanks. I haven't done as much with the prop as I'd like, but I've been dabbling with porting a newer gcc to the DSP563xx. The latest version that has been ported is gcc 1.37. Being that there seems to be no common code between 1.37 and 4.x, I don't think I can start there. Add in that the compiler is limited to half the ram in the chip and...
Sign In or Register to comment.