[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] microblaze c++ linker issue with new and delete operators
Hi Gianluca,
C++ apps are not currently supported for MicroBlaze / uClinux. While it
may be possible (as you have seen) to get simple apps going, the STL,
iostreams libraries etc will not build properly.
PetaLogix will be releasing a new toolchain soon with full C++ support
for uClinux apps - if you have an urgent need please contact me directly.
Regards,
John
Gianluca wrote:
> Hello.
> I am facing some big problems using c++ compilers on microblaze target and new and delete operator.
>
> My simple c++ programs is the following code snippet:
>
> class Prova
> {
> public:
> Prova();
> Prova(int p1, int p2);
> ~Prova();
> int somma( int a, int b );
> int uno;
> int due;
> };
>
> Prova::Prova()
> {
> uno = 7;
> due = 3;
> }
>
> Prova::Prova(int p1, int p2)
> {
> if( p1 )
> uno = p1;
> if ( p2 )
> due = p2;
> }
>
> Prova::~Prova(void)
> {
> }
>
> int Prova::somma( int a, int b )
> {
> uno = a;
> due = b;
> return uno + due;
> }
>
> int main()
> {
> Prova * pippo = new( Prova );
> int a, b;
>
> a = 7;
> b = 3;
> int c = pippo->somma(a,b);
>
> delete pippo;
>
> return c;
> }
>
> When launching compile command line:
> $ ucfront-g++ mb-g++ -c -Os -g -fomit-frame-pointer -fno-common -fno-builtin -Wall -msoft-float -mno-xl-soft-mul -mxl-barrel-shift -mno-xl-soft-div -DEMBED -Dlinux -D__linux__ -Dunix -D__uClinux__ -W -Wall -Wredundant-decls -Wshadow -Wpointer-arith -Wpacked -Wcast-qual main.cpp -o main.o
> everything was compiled fine.
>
> But when I try to link this program, here it is the first problem:
>
> ucfront-g++ mb-g++ -Wl,-elf2flt -o appmain main.o
> appmain.elf2flt: In function `main':
> /home/gianluca/main.cpp(.text+0xc8): undefined reference to `operator new(unsigned long)'
> /home/gianluca/main.cpp(.text+0x100): undefined reference to `operator delete(void*)'
> collect2: ld returned 1 exit status
> make: *** [appmain] Error 1
>
> But, if I change the main() function to:
>
> int main()
> {
> Prova pippo;
> int a, b;
>
> a = 7;
> b = 3;
> int c = pippo.somma(a,b);
>
> return c;
> }
>
> Everything is working (and linking) as expected.
> Why?
> It looks like the linker/compiler doesn't complain about dynamic memory allocation of pointers with new and delete operators.
>
> Another issue is about the linker command line:
> if using the first code snippet and OMIT the (ucfront-g++) environment system, such as:
> mb-g++ -o appmain main.o
> Everything is finishing without any error!!!
>
> Something related to syscall and gcc function call for memory allocation???
>
> Any help, clue, hint will be appreciated.
>
> Kind Regards,
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/