How to build a C++ program under CW 10.1 / MQX 3.7 MCF51AC256?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to build a C++ program under CW 10.1 / MQX 3.7 MCF51AC256?

1,559 Views
JohnBabrick
Contributor II

Hi -

 

I am getting started with CW. I can build and run a C program for MCF51AC256, but unable to get a C++ program to find standard libraries. What do I have to include to get iostreams, etc, to be found by CW and built into the image? There just doesn't seem to be any information I can find in the documentation. Would someone point me to the appropriate documents or let me know what settings I need to get a project to build with C++ libraries? 

 

Thanks

 

John Babrick

 

 

 

9 Replies

759 Views
skerr
Contributor I

I'm having the same problem with the K60 processor.  I'm also looking for documentation. If anyone can help point me in the right direction, it would be greatly appreciated.

Thanks

Steve Kerr

0 Kudos

759 Views
DavidS
NXP Employee
NXP Employee

Hi All,

FYI - Next mid-month we will release MQX3.8 that will have C++ MQX example.

Regards,

David

0 Kudos

759 Views
JohnBabrick
Contributor II

Update as of October 27th, 2011. I can get CW 10.1 with updates and MQX 3.7 to compile, build and debug/run a simple C++ program on the Tower MCF51CN. It is a quirky little system, but it does work so far. It took me three weeks of struggling to get it running. Lots of conflicting and/or out of date instructions.

 

I still don't know quite how to include iostreams, etc, but I am working on that. I am hoping that the 3.8 update will show how to setup to use the standard C++ libraries - this is an issue that is not well addressed in the instructions. 

 

My thanks to those who helped. 

0 Kudos

759 Views
jpa
Contributor IV

Is there any hope of bringing the rest of us up to speed with what you found?

 

JPA

0 Kudos

759 Views
JohnBabrick
Contributor II

Modify the user_config.h file to add 

 

#define BSPCFG_ENABLE_CPP 1

 

recompile the MQX libraries (in CW) - the bsp, psp, rtcs, mfs, shell, etc.

 

When building your project, in CW, right click the project in the project pane and select

 

properties/ c/c++ build /settings/Coldfire Compiler/Language Settings and check (at least) Force C++ Compilation (there may be more things to check but I haven't gotten that far yet. 

 

You should be able at that point to build a C++ project that does not use the C++ standard libs (i.e, but you can use c standard libs, printf). I haven't figured out yet how to get the C++ standard libs to compile, or waht exactly needs to be included - I get errors when I try to compile something with <iostream> in it. 

 

I have a TSR in to Freescale to see if they will explain what I need to do to get this working. 

0 Kudos

759 Views
JohnBabrick
Contributor II

Here is where I am at: I can either

 

1) Build and run a C++ program using standard libs but not with MQX 

 

-or-

 

2) I can build and run an MQX programthat doesn't use C++ standard libs. 

 

Option (1) results when I use the CW wizard for a bareboard project for MCF51CN128 and then load and run it on the Tower board. Unfortnuately, the console IO dribbles out of the OSBDM/OSJTAG USB port very slowly. I don't know how to get the IO to come out of the serial board's port. 

 

Option (2) results when I use the CW wizard to produce a Tower evaluation board for MQX. The console IO goes out of the serial port on the serial board, but I cannot get any calls to the C++ standard libs to build. 

 

I don't really "need" MQX but I should be able to use it, and I should be able to use it with C++. We need better documentation for how to configure the development environment correctly. I don't know which EWL libraries need to be included or which macros need to be defined. I sure wish Freescale would provide this info!

 

 

759 Views
jpa
Contributor IV

John,

 

Thanks for the information!

 

For C++/MQX, did you make any changes to the .lcf files ?  It seems to be wanting __heap_addr and __heap_size which are missing from the MQX lcf files.  

 

I've hacked something in, but not with any certainty.  There's also a message about __cxa_end_catch and __cxa_call_unexpected.  I don't use exceptions.  

 

JPA

0 Kudos

759 Views
JohnBabrick
Contributor II

I didn't do anything yet to the C++/MQX project's .lcf file. I don't know what to do.

 

I am *really*  *really*  hoping that Freescale will provide updated and complete instructions on how to use C++ with MQX in the 3.8 release, which I am lead to believe will be "soon".

0 Kudos

759 Views
jpa
Contributor IV

I'm with you about the MQX 3.8 release.  Here's hoping they've fixed lots of bugs, too.  

 

The linker problem (and solution) is discussed at 

https://community.freescale.com/message/89716#89716

 

The danger, of course, is that it's easy to implement and then forget it for the next project.  

 

JPA

0 Kudos