FPGARelated.com
Forums

uBlaze : Programming in C++... Is Possible ?

Started by Alfmyk September 22, 2006
Hi all.

Please, what are main steps to try programming in C++ on uBlaze ? It's mandatory use a XilKernel (little Kernel) provided by Xilinx? In fact some built-in C++ command like new are unavailable...

Please refer here any other possible suggestion and any issues using C++ in uBlaze environment.

Thanks in advance.

Cheers, Al.
On Fri, 22 Sep 2006 06:00:48 -0700, Alfmyk <Alfmyk@hotmail.com> wrote:

>Hi all. > >Please, what are main steps to try programming in C++ on uBlaze ? It's mandatory use a XilKernel (little Kernel) provided by Xilinx? In fact some built-in C++ command like new are unavailable... > >Please refer here any other possible suggestion and any issues using C++ in uBlaze environment. > >Thanks in advance. > >Cheers, Al.
It is possible. You may be forced to veto exceptions and floating point. In my case, I have written a multithreaded OS, pretty fast (but not RTOS, interrupts are serviced in varying time) in templated C++ and a little of assemebler, and it works really nice. I found I had to rewrite some of the standard functions and macros as provided by Xilinx, including global operator new, new[], delete and delete[] because they were too heavy-weighted fro an embedded application. BTW, no C++ will work with an EDK version before 8.1, previous versions had some unpredictable bugs in the compiler. Best regards, Zara
Hi,

C++ is indeed supported on MicroBlaze and no, it has no requirement to be 
used with Xilkernel. In fact, if anything, C++ has typically not been used 
in a multi-threaded environment, as the OS libraries need to provide 
thread-safety and re-entrancy on some key routines.

new, delete etc. are indeed available. (assuming you are using EDK 8.1i and 
post).

Some functions in the C++ STL may not be available - especially calls that 
require file system support.

There are one or two obscure bugs with exception handling, but it works for 
the most part. mb-g++ has a 95% pass rate on the DejaGNU G++ testsuite.

thanks,
Vasanth



"Alfmyk" <Alfmyk@hotmail.com> wrote in message 
news:ee9f05b.-1@webx.sUN8CHnE...
> Hi all. > > Please, what are main steps to try programming in C++ on uBlaze ? It's > mandatory use a XilKernel (little Kernel) provided by Xilinx? In fact some > built-in C++ command like new are unavailable... > > Please refer here any other possible suggestion and any issues using C++ > in uBlaze environment. > > Thanks in advance. > > Cheers, Al.
Hi. Thanks Zara & Vasanth.

Now I'm using EDK 8.1.02i and so I assume it's possible run C++ routines. Nevertheless using a very simple class: class Cliente { public: char name[20]; char surname[20]; void insert_name( ); };

and generating an object with new keyword: Client *client; client = new Client( );

I get this error: undefined reference to `operator new(unsigned long)' collect2: ld returned 1 exit status make: *** [Application/executable.elf] Error 1

should I use the mb-g++ compiler instead of mb-gcc? What else?

Thanks again.

Regards, Al.
On Mon, 25 Sep 2006 00:55:34 -0700, Alfmyk <alfmyk@hotmail.com> wrote:

>Hi. Thanks Zara & Vasanth. > >Now I'm using EDK 8.1.02i and so I assume it's possible run C++ routines. Nevertheless using a very simple class: class Cliente { public: char name[20]; char surname[20]; void insert_name( ); }; > >and generating an object with new keyword: Client *client; client = new Client( ); > >I get this error: undefined reference to `operator new(unsigned long)' collect2: ld returned 1 exit status make: *** [Application/executable.elf] Error 1 > >should I use the mb-g++ compiler instead of mb-gcc? What else? > >Thanks again. > >Regards, Al.
Either you tell the compiler to use the correct libraries, or you provide the new functions. I do the second, but the first is easier. mb-gcc will call mb-g++ when the input is *.cpp, and the proof is that it is telling you that operator new is not found. If it had been compiled as C (ant not C++), the problem would be a simple syntax error. zara
Zara wrote: 

      Either you tell the compiler to use the >correct libraries, or you provide
      the new functions. I do the second, >but the first is easier.





      mb-gcc will call mb-g++ when the input is >*.cpp, and the proof is that
      it is telling you that operator new is not >found. If it had been compiled
      as C (ant not C++), the problem >would be a simple syntax error.





      zara




Hi zara. Thanks again for your answer. I think I have understood what you mean: in fact using a my own simple makefile to compile and generate .elf file no problem at all. Using XPS environment and also trying naming .cpp file linker report always same error related to new keyword.

So perhaps there is a bug for linker invoking? Or moreover perhaps I have to set new libraries for C++ (for XPS)? anyway I try create a makefile also because I want use application in DDR RAM (I'm using a spartan 3E avaluation Board) and so I have to set linking star address for .text section and so on... But I'm finding problem to do it...

Bye, Al.
The section about "Language Dialect" (page 100) in the GNU Compiler Tools 
chapter of the Embedded Systems Tools Reference Manual is probably of use to 
you.



"Alfmyk" <alfmyk@hotmail.com> wrote in message 
news:ee9f05b.2@webx.sUN8CHnE...
> Hi. Thanks Zara & Vasanth. > > Now I'm using EDK 8.1.02i and so I assume it's possible run C++ routines. > Nevertheless using a very simple class: class Cliente { public: char > name[20]; char surname[20]; void insert_name( ); }; > > and generating an object with new keyword: Client *client; client = new > Client( ); > > I get this error: undefined reference to `operator new(unsigned long)' > collect2: ld returned 1 exit status make: *** [Application/executable.elf] > Error 1 > > should I use the mb-g++ compiler instead of mb-gcc? What else? > > Thanks again. > > Regards, Al.