简体   繁体   English

无法使用 c++17 为 arm 进行交叉编译

[英]Cannot cross-compile for arm with c++17

I am trying to cross-compile c++14/c++17 code for my raspberry pi.我正在尝试为我的树莓派交叉编译 c++14/c++17 代码。 I am sure it worked on my old PC.我确信它可以在我的旧电脑上运行。 However, when I try to compile it on my new pc, it returns me the following error.但是,当我尝试在我的新电脑上编译它时,它返回以下错误。

    $ arm-linux-gnueabihf-g++ main.cpp -std=c++17
    arm-linux-gnueabihf-g++: error: unrecognized command line option ‘-std=c++17’

I thought it is the compiler issue, the version of the compiler I am using is:我以为是编译器的问题,我使用的编译器版本是:

$ arm-linux-gnueabihf-g++ --version
arm-linux-gnueabihf-g++ (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) 4.8.3 20140303 (prerelease)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I try to get the newest compiler with我尝试使用最新的编译器

sudo apt-get install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev build-essential bison flex libssl-dev bc

Yet, the version is still the same, which can only compile c++11.但是版本还是一样,只能编译c++11。

How can I update the arm-linux-gnueabi-g++ compiler??如何更新 arm-linux-gnueabi-g++ 编译器?? I am pretty sure there is a compiler that works since I used it before, but not sure how I get it.我很确定有一个编译器可以工作,因为我以前使用过它,但不确定我是如何得到它的。

I found the easiest way to solve this issue is to directly install the newest cross-compiler我发现解决这个问题最简单的方法是直接安装最新的交叉编译器

sudo apt-get install g++-9-arm-linux-gnueabihf

and use the compiler as (just an example of using c++17)并使用编译器作为(只是使用 c++17 的一个例子)

arm-linux-gnueabihf-g++-9 main.cpp -std=c++17

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM