CLion - error: 'nullptr' was not declared in this scope

I keep getting this error message when building PLATFORMIO_BUILD from CLion

… .platformio/packages/framework-arduinoespressif8266/cores/esp8266/Arduino.h:279:48: error: ‘nullptr’ was not declared in this scope
const char* server1, const char* server2 = nullptr, const char* server3 = nullptr);
when I build from CLion…
pio run and pio run --target upload runs without an issue when run from command line.

.platformio/packages/framework-arduinoespressif8266/cores/esp8266/HardwareSerial.h:108:23: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 [enabled by default]
int available(void) override;
^
In CLion settings I tried both the bundled cmake and gdb as well as my system one (/usr/bin/cmake, /usr/bin.gdb).

Versions:

  • CLion bundled ones:
    • CMake: 3.6.3
    • GDB: 7.11.1
  • System wide versions are:
  • CMake 3.5.1
  • GDB: GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1

This is my first PlatformIO project after a while, last time I also used CLion but had no issues, this was on a different linux distro though.

This is platformio.ini:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino

From searching online it seems that the issue might be that CLion compiles it with different -std parameter? I tried to sprinkle -std=gnu++11 wherever I could but it didn’t help.

Could anyone please point me in the right direction? I know nothing about these build systems…

Could you try the latest development version of PIo Core and re-init project?

Thanks for the reply, I reinstalled as suggested and it now works!

Now that I think of it I might have also been pressing run instead of build, can’t remember to be honest.

And so after reinstalling I am able to build from IDE:
PLTFORMIO_BUILD, PLATFORMIO_UPLOAD, PLATFORMIO_CLEAN, PLATFORMIO_UPDATE all work as expected.

The problem I am facing now is that after I run PLATFORMIO_REBUILD_PROJECT_INDEX once:

/usr/bin/cmake --build /home/fuho/Projects/ir_blaster/cmake-build-debug --target PLATFORMIO_REBUILD_PROJECT_INDEX – -j 8

The current working directory /home/fuho/Projects/ir_blaster will be used for project.
You can specify another project directory via
platformio init -d %PATH_TO_THE_PROJECT_DIR% command.

The next files/directories have been created in /home/fuho/Projects/ir_blaster
platformio.ini - Project Configuration File
src - Put your source files here
lib - Put here project specific (private) libraries

Project has been successfully initialized!
Useful commands:
platformio run - process/build project from the current directory
platformio run --target upload or platformio run -t upload - upload firmware to embedded board
platformio run --target clean - clean project (remove compiled files)
platformio run --help - additional information
Built target PLATFORMIO_REBUILD_PROJECT_INDEX

… the build system breaks (result of PLATFORMIO_BUILD):

/usr/bin/cmake --build /home/fuho/Projects/ir_blaster/cmake-build-debug --target PLATFORMIO_BUILD – -j 8
/bin/sh: 1: platformio: not found
CMakeFiles/PLATFORMIO_BUILD.dir/build.make:57: recipe for target ‘CMakeFiles/PLATFORMIO_BUILD’ failed
make[3]: *** [CMakeFiles/PLATFORMIO_BUILD] Error 127
CMakeFiles/Makefile2:141: recipe for target ‘CMakeFiles/PLATFORMIO_BUILD.dir/all’ failed
make[2]: *** [CMakeFiles/PLATFORMIO_BUILD.dir/all] Error 2
CMakeFiles/Makefile2:153: recipe for target ‘CMakeFiles/PLATFORMIO_BUILD.dir/rule’ failed
make[1]: *** [CMakeFiles/PLATFORMIO_BUILD.dir/rule] Error 2
Makefile:144: recipe for target ‘PLATFORMIO_BUILD’ failed
make: *** [PLATFORMIO_BUILD] Error 2

… I assume this is because CMakeListsPrivate.txt doesn’t have correct location for the platformio command?

set(ENV{PATH} “/home/fuho/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin”)
set(PLATFORMIO_CMD “platformio”)

I installed Platformio using pip2.7 --user so the executable is at /home/fuho/.local/bin/platformio.

Is the CMakeListsPrivate.txt generated automatically or can I make my edits there?

That is a bug. Please open an issue here Issues · platformio/platformio-core · GitHub

Use your system terminal where pio command is available and manually rebuild index via pio init --ide clion

Created… but as I dig into it more it seems to be an issue with CLion not Platformio…

As CLion runs scripts it’s supposed to pass system environment variables but somehow the PATH is different than the one when I run it from terminal. The /home/$user/.local/bin is missing completely for example.

My assumption is that util.where_is_program and to be exact util.exec_command then fails to find the correct path for platformiousing which, so it defaults to platformio, and this is then stored in CMakeListsPrivate.txt and then used during the build process. Since the build process is run from the IDE and the IDE doesn’t have the full PATH variable this then fails.

So the workaround would be to fix the path in IDE settings maybe…