0

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?

4
4

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.

5
  • Ack! How did you find the version of gcc I'm using? I don't see it in the text.
    – Thom
    May 11 at 12:03
  • @Thom from your mention of the raspberrypi/tools in your other post, you can see the version here: github.com/raspberrypi/tools/tree/master/arm-bcm2708/…, or you can verify it yourself using arm-linux-gnueabihf-gcc --version
    – tttapa
    May 11 at 12:08
  • I have my project building with this. Cheers for this. Where does the executable go?
    – Thom
    May 11 at 16:20
  • @Thom which executable? The one you built is probably in a “build” folder somewhere.
    – tttapa
    May 11 at 18:35
  • looked under the tmp directory, and the project directory and couldn't find a dir named build. This is annoying. It says Build files have been written to: /tmp/tmp.UNnm1OGKQ2/cmake-build-raspberry-pi-release
    – Thom
    May 11 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.