CANNOT #include <iostream> for External modules

I’m trying to add my custom module for the PX4 autopilot. Everything is fine if I add it inside the PX4 tree (i.e. next to src/examples/px4_simple_app), however I’d like to have it in separate folder and build the autopilot using EXTERNAL_MODULES_LOCATION flag.

I encounter the following error while building:

fatal error: iostream: No such file or directory
40 | #include <iostream>

I believe that it is built as C++ code, since I can add classes in it. Also it builds successfully for target px4_stil, but not for px4_fmu-v3_default.

Would be happy for any advice,
Kind regards,

The C++ STL is not available within the PX4/NuttX build. To print to console, just use printf() or PX4_INFO().

Thanks for the reply.
I wonder why am I able to make px4_stil EXTERNAL_MODULES_LOCATION=/path/to/ext in that case ? Also, I can make px4_fmu-v3_default successfully if I add my C++ module inside the px4 tree. The issue comes only if I make px4_fmu-v3_default EXTERNAL_MODULES_LOCATION=/path/to/ext.
Am I missing something(maybe in CMakeLists.txt) ?
I’m using Px4 Autopilot 1.14 release version.