【问题标题】:compiling kernel 3.x.x on ubuntu 20在 ubuntu 20 上编译内核 3.x.x
【发布时间】:2020-05-08 19:50:44
【问题描述】:

我需要为 armhf 编译内核 3.4,这需要 gcc-4.9。
cmd 行是:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- tegra_defconfig(这里我不确定是否需要设置 CROSS_COMPILE)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

问题是我无法让 ubuntu 使用 gcc-4.9,这是不可用的,我不得不将 xenial 添加到“sources.list”文件中,现在我的系统上有它但无法使用它。
CC=gcc-4.9 添加到命令将不会使用CROSS_COMPILE 定义的arm-linux-gnueabihf 前缀。
update-alternatives 不会将 gcc-4.9 识别为第二个 c 编译器。 有谁知道解决这个问题的方法吗?
请不要只发表“安装 xenial”之类的评论。

【问题讨论】:

  • 你可以在运行make之前尝试这些命令:update-alternatives --set gcc "/usr/bin/gcc-4.9"update-alternatives --set g++ "/usr/bin/g++-4.9"。准备好后不要忘记将其反转为当前版本。
  • 谢谢,但在我编辑之前你可能已经回答了:输出是:update-alternatives: error: no alternatives for gcc
  • @flappix 我的默认编译器是 gcc-9,我尝试安装 gcc-10 认为它可能会解锁 update-alternatives 功能以将其设置为 4.9 但即使安装了 gcc-10 我也得到了相同的结果我在上一条评论中提到的错误。

标签: cross-compiling compatibility


【解决方案1】:

来自这个帖子:How to change the default GCC compiler in Ubuntu?

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
sudo update-alternatives --set gcc /usr/bin/gcc-4.9
gcc --version
gcc (Ubuntu 4.9.3-13ubuntu2) 4.9.3
Copyright (C) 2015 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.

坚持我的情况(交叉编译):

sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-4.9 50
sudo update-alternatives --set arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-4.9

对于内核 3.x.x 和更旧的 perl 是必需的,您可以在完成 perlbrew initperlbrew install perl-5.10.0 之后使用 perlbrew use perl-5.10.0 克服错误(仔细阅读最后两个命令的输出)。

请注意,即使在交叉编译时,您也需要将主机的 gcc 设置为 4.9 因为配置生成器需要它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-14
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    相关资源
    最近更新 更多