C++ hello world project in MCUXPresso IDE

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

C++ hello world project in MCUXPresso IDE

Jump to solution
3,706 Views
azhar
Contributor III

Hello.

I am able to compile and run C hello world project (from new project template) on RT1064. However, C++ hello world project (from new project template) compiles and runs but there is no output on the console. I am connecting through jtag. Any ideas about working in C++ is highly appreciated.

Thanks

Azhar

0 Kudos
Reply
1 Solution
3,663 Views
converse
Senior Contributor V

Check the SDK Debug Console settings - read the MCUXpresso User Manual for details. I think you have it set to use the UART instead of the console. If you want to guarantee that you are using the console, use printf instead of PRINTF.

Another note: You need to understand the difference between newlibnano and newlib wrt C++ - newlibnano (for example) does not support exceptions. This is again described in the User Manual.

View solution in original post

10 Replies
3,692 Views
azhar
Contributor III

Thanks converse for the response. According to this post : What are Redlib and Newlib? - NXP Community

Newlib is c++ library. More instructions are at: Switching the selected C library - NXP Community

In the linker settings, I tried both Newlib(semihost) and NewlibNano(semihost) but the result is the same no output on the console. Let me know if something else needed to be changed?

0 Kudos
Reply
3,686 Views
converse
Senior Contributor V

Export and post your project here. There are several settings to do with where output is placed. However, C++ I/O is very memory hungry, so may not be suitable to use in an embedded environment anyway. 

btw: what is you chip/board?

0 Kudos
Reply
3,681 Views
azhar
Contributor III

The problem is It seems running fine (no errors about memory etc). It just doesn't display output at the console.

0 Kudos
Reply
3,683 Views
azhar
Contributor III

Device is RT1064.

Here are the exported project settings... (xml is not supported for attachment here, so I paste it below)

<?xml version="1.0" encoding="UTF-8"?>
<cdtprojectproperties>
<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths">
<language name="C++ Source File">
<includepath workspace_path="true">/${ProjName}/board</includepath>
<includepath workspace_path="true">/${ProjName}/source</includepath>
<includepath workspace_path="true">/${ProjName}/drivers</includepath>
<includepath workspace_path="true">/${ProjName}/xip</includepath>
<includepath workspace_path="true">/${ProjName}/component/serial_manager</includepath>
<includepath workspace_path="true">/${ProjName}/component/uart</includepath>
<includepath workspace_path="true">/${ProjName}/utilities</includepath>
<includepath workspace_path="true">/${ProjName}/component/lists</includepath>
<includepath workspace_path="true">/${ProjName}/CMSIS</includepath>
<includepath workspace_path="true">/${ProjName}/device</includepath>

</language>
<language name="C Source File">
<includepath workspace_path="true">/${ProjName}/board</includepath>
<includepath workspace_path="true">/${ProjName}/source</includepath>
<includepath workspace_path="true">/${ProjName}/drivers</includepath>
<includepath workspace_path="true">/${ProjName}/xip</includepath>
<includepath workspace_path="true">/${ProjName}/component/serial_manager</includepath>
<includepath workspace_path="true">/${ProjName}/component/uart</includepath>
<includepath workspace_path="true">/${ProjName}/utilities</includepath>
<includepath workspace_path="true">/${ProjName}/component/lists</includepath>
<includepath workspace_path="true">/${ProjName}/CMSIS</includepath>
<includepath workspace_path="true">/${ProjName}/device</includepath>

</language>
<language name="Assembly Source File">
<includepath workspace_path="true">/${ProjName}/board</includepath>
<includepath workspace_path="true">/${ProjName}/source</includepath>

</language>
<language name="Additional Assembly Source Files">
<includepath workspace_path="true">/${ProjName}/board</includepath>
<includepath workspace_path="true">/${ProjName}/source</includepath>

</language>
<language name="Object File">

</language>
</section>
<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros">
<language name="C++ Source File">
<macro>
<name>CPU_MIMXRT1064DVL6A</name><value/>
</macro>
<macro>
<name>CPU_MIMXRT1064DVL6A_cm7</name><value/>
</macro>
<macro>
<name>FSL_RTOS_BM</name><value/>
</macro>
<macro>
<name>SDK_OS_BAREMETAL</name><value/>
</macro>
<macro>
<name>XIP_EXTERNAL_FLASH</name><value>1</value>
</macro>
<macro>
<name>XIP_BOOT_HEADER_ENABLE</name><value>1</value>
</macro>
<macro>
<name>SERIAL_PORT_TYPE_UART</name><value>1</value>
</macro>
<macro>
<name>SDK_DEBUGCONSOLE</name><value>0</value>
</macro>
<macro>
<name>__MCUXPRESSO</name><value/>
</macro>
<macro>
<name>__USE_CMSIS</name><value/>
</macro>
<macro>
<name>DEBUG</name><value/>
</macro>
<macro>
<name>__NEWLIB__</name><value/>
</macro>

</language>
<language name="C Source File">
<macro>
<name>__NEWLIB__</name><value/>
</macro>
<macro>
<name>CPU_MIMXRT1064DVL6A</name><value/>
</macro>
<macro>
<name>CPU_MIMXRT1064DVL6A_cm7</name><value/>
</macro>
<macro>
<name>FSL_RTOS_BM</name><value/>
</macro>
<macro>
<name>SDK_OS_BAREMETAL</name><value/>
</macro>
<macro>
<name>XIP_EXTERNAL_FLASH</name><value>1</value>
</macro>
<macro>
<name>XIP_BOOT_HEADER_ENABLE</name><value>1</value>
</macro>
<macro>
<name>SERIAL_PORT_TYPE_UART</name><value>1</value>
</macro>
<macro>
<name>SDK_DEBUGCONSOLE</name><value>0</value>
</macro>
<macro>
<name>__MCUXPRESSO</name><value/>
</macro>
<macro>
<name>__USE_CMSIS</name><value/>
</macro>
<macro>
<name>DEBUG</name><value/>
</macro>

</language>
<language name="Assembly Source File">

</language>
<language name="Additional Assembly Source Files">

</language>
<language name="Object File">

</language>
</section>
</cdtprojectproperties>

0 Kudos
Reply
3,675 Views
converse
Senior Contributor V

I asked for the project, not the settings. Please export the project (as a zip file) and post it here.

0 Kudos
Reply
3,671 Views
azhar
Contributor III

Here.

0 Kudos
Reply
3,664 Views
converse
Senior Contributor V

Check the SDK Debug Console settings - read the MCUXpresso User Manual for details. I think you have it set to use the UART instead of the console. If you want to guarantee that you are using the console, use printf instead of PRINTF.

Another note: You need to understand the difference between newlibnano and newlib wrt C++ - newlibnano (for example) does not support exceptions. This is again described in the User Manual.

3,658 Views
azhar
Contributor III

I was able to resolve by setting preprocessor by SDK_DEBUGCONSOLE=1. The new project template creates this to be 0 by default.

0 Kudos
Reply
3,697 Views
converse
Senior Contributor V
0 Kudos
Reply
3,689 Views
azhar
Contributor III

Thanks converse for the response. According to this post : What are Redlib and Newlib? - NXP Community

Newlib is c++ library. More instructions are at: Switching the selected C library - NXP Community

In the linker settings, I tried both Newlib(semihost) and NewlibNano(semihost) but the result is the same no output on the console. Let me know if something else needed to be changed?

0 Kudos
Reply