6

I need to compile a program for Raspberry PI 3+ on Linux machine, and code must be compliant with c++17 standard. Official toolchain is outdated and lack c++17 compilation option. Two solutions that I can see right now are:

1) gcc has an option -march, which described here: https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

2) Installing arm-linux-gbueabi-gcc package, as proposed here: Cross-compiling for Raspberry pi with modern gcc

What is the difference between two options? Is there some other possibilities that will work?

stackoverflower
  • 545
  • 1
  • 5
  • 21
  • 1
    You could install a modern compiler on the Pi (it probably already has one if it's running a reasonably up-to-date distribution) and then simply compile the code *on the Pi*. – Jesper Juhl Sep 26 '18 at 15:24
  • 1
    That is the point, because on the Pi my project will take 12+ hours to compile, and each change of code will be painful. – stackoverflower Sep 26 '18 at 15:33
  • 3
    That's painful. But if it takes 12 hours I would imagine you have some build system issues you could address to make it faster. Like: Install and use `ccache` it helps enormously with subsequent builds. Make sure your build system dependencies are correct so you only rebuild what's needed. Make extensive use of forward declarations, extern templates etc, where possible, rather than including full definitions. Don't include unneeded headers. Etc etc. Doing those things would also speed up your non-Pi builds. – Jesper Juhl Sep 26 '18 at 15:38
  • 1
    C++ builds are very easy to make slow, but can be made fast(er) (significantly so) with some effort. The ~500K line code base I work with used to take ~40min to build on a 32core machine 6 years ago. We've gotten that down to ~10min for a full build (on a 20 core machine), 3min for most rebuilds with minor changes. It took some work, but the end result was a massive improvement. – Jesper Juhl Sep 26 '18 at 15:47
  • The code compiling opencv from scratch (latest code, and it constantly change), and have some amount of templates, too, which increases time. Anyway, it is easier to compile on Raspberry Pi, but the time is precious – stackoverflower Sep 26 '18 at 16:03
  • Have you tried -march? Did it work? – n. m. could be an AI Mar 07 '19 at 05:26
  • No, because someone told me that it can't work, because anyway will be a lot of problems on linking stage – stackoverflower Mar 18 '19 at 15:06
  • @n.1.8e9-where's-my-sharem.: `-march` just sets CPU options within the current target, e.g. `-march=znver2` to use AVX2+FMA + everything else Zen 2 has, and tune for Zen 2 CPUs. This only works with x86-64 GCC. GCC has no equivalent to `clang -target arm` or `-target mips64`. (GCC does have `-m32` or `-m64` to make x86-64 GCC output i386 or x86-64 asm, but that's all, just variations within highly-related targets.) – Peter Cordes Jun 13 '21 at 11:38

1 Answers1

1

If you want full Cross Compiler c++17 standard for your Raspberry Pi, you can try my Latest Pre-Built/Pre-Compiled Open-Sourced GCC Toolchains for Raspberry Pi along with well-documented instructions from this Github Repo:

The GCC versions available as of now are as follows:

  • GCC 6.3.0
  • GCC 7.4.0
  • GCC 8.2.0
  • GCC 8.3.0

And, the Supported Environments:

  • Cross-Compiler: All Linux Distros (x32/x64) are currently supported.
  • Native-Compiler: All Raspberry Pi version/model with Raspbian OS is supported. Other OS may/may-not work.

also the currently Supported Languages are:

  • C++
  • C
  • Fortran
abhiTronix
  • 1,248
  • 13
  • 17