Last active
August 27, 2024 09:53
-
-
Save sol-prog/95e4e7e3674ac819179acf33172de8a9 to your computer and use it in GitHub Desktop.
Install GCC 9 on Raspberry Pi and build C++17 programs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'; | |
} | |
} |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.