-
-
Save sol-prog/95e4e7e3674ac819179acf33172de8a9 to your computer and use it in GitHub Desktop.
# Commands used in the video https://youtu.be/-bCG87jBDqA : | |
sudo apt update && sudo apt upgrade -y | |
git clone https://bitbucket.org/sol_prog/raspberry-pi-gcc-binary.git | |
cd raspberry-pi-gcc-binary | |
tar -xjvf gcc-9.1.0-armhf-raspbian.tar.bz2 | |
sudo mv gcc-9.1.0 /opt | |
cd .. | |
rm -rf raspberry-pi-gcc-binary | |
cd ~ | |
echo 'export PATH=/opt/gcc-9.1.0/bin:$PATH' >> ~/.bashrc | |
echo 'export LD_LIBRARY_PATH=/opt/gcc-9.1.0/lib:$LD_LIBRARY_PATH' >> ~/.bashrc | |
. ~/.bashrc | |
sudo ln -s /usr/include/arm-linux-gnueabihf/sys /usr/include/sys | |
sudo ln -s /usr/include/arm-linux-gnueabihf/bits /usr/include/bits | |
sudo ln -s /usr/include/arm-linux-gnueabihf/gnu /usr/include/gnu | |
sudo ln -s /usr/include/arm-linux-gnueabihf/asm /usr/include/asm | |
sudo ln -s /usr/lib/arm-linux-gnueabihf/crti.o /usr/lib/crti.o | |
sudo ln -s /usr/lib/arm-linux-gnueabihf/crt1.o /usr/lib/crt1.o | |
sudo ln -s /usr/lib/arm-linux-gnueabihf/crtn.o /usr/lib/crtn.o | |
g++-9.1 -std=c++17 -Wall -pedantic test_fs.cpp -o test_fs | |
./test_fs |
// Build/compile with: | |
// g++-9.1 -std=c++17 -Wall -pedantic test_fs.cpp -o test_fs | |
#include <iostream> | |
#include <filesystem> | |
int main() { | |
for(auto &file : std::filesystem::recursive_directory_iterator("./")) { | |
std::cout << file.path() << '\n'; | |
} | |
} |
Thanks!
just tried on my rpi model 3 b+ and for both gcc-9.1.0 and gcc-10.1.0 (which also happened to be in the archive file) it fails with following error:
command: g++-10.1 -std=c++17 -Wall -pedantic test_fs.cpp -o test_fs
In file included from /opt/gcc-10.1.0/include/c++/10.1.0/arm-linux-gnueabihf/bits/os_defines.h:39,
from /opt/gcc-10.1.0/include/c++/10.1.0/arm-linux-gnueabihf/bits/c++config.h:518,
from /opt/gcc-10.1.0/include/c++/10.1.0/iostream:38,
from test_fs.cpp:3:
/usr/include/features.h:424:12: fatal error: sys/cdefs.h: No such file or directory
424 | # include <sys/cdefs.h>
| ^~~~~~~~~~~~~
compilation terminated.
Any ideas?
Double check if you've executed all the symbolic links commands (you will beed to adapt these for your GCC 10.1.0 if necessary). It seems to me that some header files are not found so one of the symbolic links from commands.sh was not properly adapted to your case.
Here is a text version of the video tutorial https://solarianprogrammer.com/2017/12/08/raspberry-pi-raspbian-install-gcc-compile-cpp-17-programs/ it may be easier to see the commands.
I have tripple checked, and followed the steps for 9.1.0 version first, only then tried 10.1.0 when the 9.1.0 didn't work..
additionally, tried the link you've just provided me with - i have exactly the same error:
pi@bo100nka-pi:~ $ g++-10.1 -std=c++17 -Wall -pedantic if_test.cpp -o if_test
In file included from /opt/gcc-10.1.0/include/c++/10.1.0/arm-linux-gnueabihf/bits/os_defines.h:39,
from /opt/gcc-10.1.0/include/c++/10.1.0/arm-linux-gnueabihf/bits/c++config.h:518,
from /opt/gcc-10.1.0/include/c++/10.1.0/iostream:38,
from if_test.cpp:1:
/usr/include/features.h:424:12: fatal error: sys/cdefs.h: No such file or directory
424 | # include <sys/cdefs.h>
| ^~~~~~~~~~~~~
compilation terminated.
Thanks for checking again. I will try on a fresh Raspbian OS install and let you know.
So I did a complete test, I installed the latest Rasperry Pi OS 32 bits Lite, did an upgrade & update, followed exactly the procedure described in the linked article and now I'm able to build C++ programs with GCC 10.1.
I have tripple checked, and followed the steps for 9.1.0 version first, only then tried 10.1.0 when the 9.1.0 didn't work..
additionally, tried the link you've just provided me with - i have exactly the same error:
pi@bo100nka-pi:~ $ g++-10.1 -std=c++17 -Wall -pedantic if_test.cpp -o if_test In file included from /opt/gcc-10.1.0/include/c++/10.1.0/arm-linux-gnueabihf/bits/os_defines.h:39, from /opt/gcc-10.1.0/include/c++/10.1.0/arm-linux-gnueabihf/bits/c++config.h:518, from /opt/gcc-10.1.0/include/c++/10.1.0/iostream:38, from if_test.cpp:1: /usr/include/features.h:424:12: fatal error: sys/cdefs.h: No such file or directory 424 | # include <sys/cdefs.h> | ^~~~~~~~~~~~~ compilation terminated.
same error here, I tried search those header files, found them under
/usr/include/arm-linux-gnueabihf/sys/
so I copied them to include
sudo cp /usr/include/arm-linux-gnueabihf/sys/* /usr/include/sys/
done
yes, this resolved the problem for me too, thanks a lot
I had to use 'sudo git clone...', 'sudo tar..' and 'sudo rm -f ...'