C++ hello world project in MCUXPresso IDE

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

C++ hello world project in MCUXPresso IDE

跳至解决方案
3,710 次查看
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 项奖励
回复
1 解答
3,667 次查看
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.

在原帖中查看解决方案

10 回复数
3,696 次查看
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 项奖励
回复
3,690 次查看
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 项奖励
回复
3,685 次查看
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 项奖励
回复
3,687 次查看
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 项奖励
回复
3,679 次查看
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 项奖励
回复
3,675 次查看
azhar
Contributor III

Here.

0 项奖励
回复
3,668 次查看
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,662 次查看
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 项奖励
回复
3,701 次查看
converse
Senior Contributor V
0 项奖励
回复
3,693 次查看
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 项奖励
回复