Including <iostream> with LwIP stack causes compiler errors (C++ project)

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

Including <iostream> with LwIP stack causes compiler errors (C++ project)

2,384 Views
rshipman
Contributor V

Hi,

If I create a C++ project in MCUXpresso:

  • File->New->New C/C++ Project->evkmimxrt1020
  • Project Type: C++ Project
  • Project Options: UART
  • Leave everything as default apart from:
  • Middleware:
    • Network->lwIP TCPIP Networking Stack->lwIP
  • Drivers:
    • enet

Add the following line to the main .cpp file (e.g. MIMXRT1021xxxxx_Project.cpp), after all the default includes:

#include <iostream>

Build Project.

I get the following compiler errors <snippet>:

Invoking: MCU C Compiler
arm-none-eabi-gcc -D__NEWLIB__ -DCPU_MIMXRT1021DAG5A -DCPU_MIMXRT1021DAG5A_cm7 -DFSL_RTOS_BM -DSDK_OS_BAREMETAL -DXIP_EXTERNAL_FLASH=1 -DXIP_BOOT_HEADER_ENABLE=1 -DSERIAL_PORT_TYPE_UART=1 -DSDK_DEBUGCONSOLE=1 -D__MCUXPRESSO -D__USE_CMSIS -DDEBUG ....lots of -I..... -O0 -fno-common -g3 -Wall -c -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -fmerge-constants -fmacro-prefix-map="../lwip/src/netif/ppp/"=. -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -D__NEWLIB__ -fstack-usage -MMD -MP -MF"lwip/src/netif/ppp/auth.d" -MT"lwip/src/netif/ppp/auth.o" -MT"lwip/src/netif/ppp/auth.d" -o "lwip/src/netif/ppp/auth.o" "../lwip/src/netif/ppp/auth.c"
In file included from c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\system_error:39,
from c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\bits\ios_base.h:46,
from c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\ios:42,
from c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\ostream:38,
from c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\iostream:39,
from ../source/MIMXRT1021xxxxx_Project.cpp:43:
c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\arm-none-eabi\thumb\v7e-m+fp\hard\bits\error_constants.h:122:27: error: 'ENOTSUP' was not declared in this scope
not_supported = ENOTSUP,
^~~~~~~
c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\arm-none-eabi\thumb\v7e-m+fp\hard\bits\error_constants.h:122:27: note: suggested alternative: 'ENOCSI'
not_supported = ENOTSUP,
^~~~~~~
ENOCSI
c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\arm-none-eabi\thumb\v7e-m+fp\hard\bits\error_constants.h:126:31: error: 'ECANCELED' was not declared in this scope
operation_canceled = ECANCELED,
^~~~~~~~~
c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\arm-none-eabi\thumb\v7e-m+fp\hard\bits\error_constants.h:135:24: error: 'EOWNERDEAD' was not declared in this scope
owner_dead = EOWNERDEAD,
^~~~~~~~~~
Finished building: ../startup/startup_mimxrt1021.cpp
c:\nxp\mcuxpressoide_11.1.0_3209\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.1.0.201909161352\tools\arm-none-eabi\include\c++\8.3.1\arm-none-eabi\thumb\v7e-m+fp\hard\bits\error_constants.h:151:34: error: 'ENOTRECOVERABLE' was not declared in this scope
state_not_recoverable = ENOTRECOVERABLE,
^~~~~~~~~~~~~~~

(Take out the extra include and it compiles ok.)

I had a quick look at the header files and tried including <sys/errno.h> before including <iostream>. It compiles. (And I can output stuff with std::cout as long as I set SDK_DEBUGCONSOLE_UART=1.)

The main function is the default apart from the extra include(s).

The preprocessor symbols are the same as a raw C++/UART project without the lwip stack.

Without doing lots of digging I cannot see how including the lwip stack (and not using it) can have this effect. Perhaps it is setting a preprocessor symbol or including a header file somehow. It is not obvious.

Any ideas?

Many thanks.

RT1020-EVK

MCUXpresso IDE v11.1.0 [Build 3209] [2019-12-12]

SDK version 2.7.0

Windows 10

Labels (1)
0 Kudos
Reply
1 Reply

2,198 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Ronnie,

 

Please check the below community thread where this question has already been answered.

 

I did not compile "Hello World" .cpp code in MCUXpresso 

 

Hope it helps!

 

Best regards,

Felipe

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply