1

Still scraping rust off of C++ and learning CLion, Raspberry Pi and Cmake. I am following https://blog.monotok.org/compile-locally-run-raspberry-pi-via-clion/ to cross-compile on my Ubuntu platform.

I have code that compiles fine locally, but when I cross-compile for raspberry pi, I get the following:

====================[ Build | rookery_exe | Raspberry Pi Release ]==============
/snap/bin/cmake --build /tmp/tmp.UNnm1OGKQ2/cmake-build-raspberry-pi-release --target rookery_exe -- -j 12
[ 10%] Building CXX object src/core/CMakeFiles/rookery_core.dir/CodeSource.cpp.o
[ 20%] Building CXX object src/core/CMakeFiles/rookery_core.dir/ArduinoSourceProperties.cpp.o
[ 30%] Building CXX object src/core/CMakeFiles/rookery_core.dir/Arduino.cpp.o
[ 50%] Building CXX object src/core/CMakeFiles/rookery_core.dir/WorkFile.cpp.o
[ 50%] Building CXX object src/core/CMakeFiles/rookery_core.dir/PropertiesFile.cpp.o
/tmp/tmp.UNnm1OGKQ2/src/core/WorkFile.cpp:1:22: fatal error: filesystem: No such file or directory
 #include <filesystem>
                      ^
compilation terminated.
In file included from /tmp/tmp.UNnm1OGKQ2/src/core/CodeSource.cpp:2:0:
/tmp/tmp.UNnm1OGKQ2/src/core/Arduino.h:5:22: fatal error: filesystem: No such file or directory
 #include <filesystem>
                      ^
compilation terminated.
gmake[3]: *** [src/core/CMakeFiles/rookery_core.dir/build.make:111: src/core/CMakeFiles/rookery_core.dir/CodeSource.cpp.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[3]: *** [src/core/CMakeFiles/rookery_core.dir/build.make:150: src/core/CMakeFiles/rookery_core.dir/WorkFile.cpp.o] Error 1
/tmp/tmp.UNnm1OGKQ2/src/core/ArduinoSourceProperties.cpp:1:22: fatal error: filesystem: No such file or directory
 #include <filesystem>
                      ^
compilation terminated.
gmake[3]: *** [src/core/CMakeFiles/rookery_core.dir/build.make:85: src/core/CMakeFiles/rookery_core.dir/ArduinoSourceProperties.cpp.o] Error 1
/tmp/tmp.UNnm1OGKQ2/src/core/PropertiesFile.cpp:3:22: fatal error: filesystem: No such file or directory
 #include <filesystem>
                      ^
compilation terminated.
gmake[3]: *** [src/core/CMakeFiles/rookery_core.dir/build.make:124: src/core/CMakeFiles/rookery_core.dir/PropertiesFile.cpp.o] Error 1
In file included from /tmp/tmp.UNnm1OGKQ2/src/core/Arduino.cpp:7:0:
/tmp/tmp.UNnm1OGKQ2/src/core/Arduino.h:5:22: fatal error: filesystem: No such file or directory
 #include <filesystem>
                      ^
compilation terminated.
gmake[3]: *** [src/core/CMakeFiles/rookery_core.dir/build.make:72: src/core/CMakeFiles/rookery_core.dir/Arduino.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:203: src/core/CMakeFiles/rookery_core.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:236: src/exe/CMakeFiles/rookery_exe.dir/rule] Error 2
gmake: *** [Makefile:182: rookery_exe] Error 2

Maybe the cross compiler uses an older version of C++ that doesn't have file system? Is there a way to fix that? Maybe a compile flag?

Thom
  • 127
  • 1
  • 7

1 Answers1

5

The raspberrypi/tools toolchain you seem to be using contains an ancient version of GCC (4.9.3). If you want to use the <filesystem> header, you need GCC 8 or later.

You can use Crosstool-NG to configure and build a newer toolchain.
Alternatively, you can find the toolchains I'm using here: tttapa/tttapa/RPi-Cpp-Toolchain. The pre-built Docker container you can download ships with GCC 9.2.0, but you can change that in the ct-ng config files, e.g. here, or by following these instructions.
I'm sure there are other distributions of newer toolchains for the Raspberry Pi as well, but I'm not familiar with them.

tttapa
  • 1,006
  • 6
  • 8