AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题

问题[cross-compilation](ubuntu)

Martin Hope
user5265160
Asked: 2019-11-13 09:51:28 +0800 CST

debian交叉打包时如何设置CC环境变量

  • 5

我正在尝试在我的 AMD64 Ubuntu 操作系统上为 ARM64 平台构建一个 debian 包。我执行命令

debuild -us -uc --host-arch arm64

但得到警告

dpkg-architecture: warning: specified GNU system type aarch64-linux-gnu does not match CC system type x86_64-linux-gnu, try setting a correct CC environment variable

因此想知道如何设置 CC 环境变量,如警告所示。对于我的目标操作系统,我通常会使用

/opt/l4t-gcc-toolchain-64-bit-32.1/install/bin/aarch64-linux-gnu-gcc

谢谢。

debian gcc cross-compilation
  • 1 个回答
  • 1859 Views
Martin Hope
Anisyanka
Asked: 2019-10-16 05:27:36 +0800 CST

交叉编译器路径

  • 4

我有一些针对不同架构的编译器:

$ > whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/share/man/man1/gcc.1.gz

$ > whereis arm-linux-gnueabi-gcc
arm-linux-gnueabi-gcc: /usr/bin/arm-linux-gnueabi-gcc /usr/share/man/man1/arm-linux-gnueabi-gcc.1.gz

$ > whereis arm-linux-gnueabihf-gcc
arm-linux-gnueabihf-gcc: ~/.local/bin/arm-linux-gnueabihf-gcc

gcc 适用于我的工作站。它安装在系统路径中。

arm-linux-gnueabi-gcc 用于没有硬浮点的 ARM 目标。它也安装在系统路径中。

arm-linux-gnueabihf-gcc 用于带有硬浮点的 ARM 目标。它安装在我的$(HOME)/.local/目录中。我已将此目录添加到.bashrc脚本中的二进制路径:

export PATH="$HOME/.local/bin:$PATH"

system 命令whereis适用于所有这些编译器,并显示二进制可执行文件的有效路径。

我想用帮助arm-linux-gnueabihf-gcc编译器为 ARM 编译一些项目,但我收到了这个:

as: unrecognised option '-mcpu=cortex-a53'

汇编期间出错。似乎我的构建系统希望为我的 x86 使用汇编程序,而不是arm-linux-gnueabihf-as.

安装arm-linux-gnueabihf到~/.local其中后,会出现一些目录:

 ~/.local> ls -l
arm-linux-gnueabihf/
bin/
gcc-linaro-5.3.1-2016.05-linux-manifest.txt
include/
lib/
libexec/
share/

如果我去,bin/我会看到二进制文件:

arm-linux-gnueabihf-addr2line*  arm-linux-gnueabihf-cpp*        arm-linux-gnueabihf-gcc-ar*      arm-linux-gnueabihf-gdb*       arm-linux-gnueabihf-nm*       arm-linux-gnueabihf-size*     isort*
arm-linux-gnueabihf-ar*         arm-linux-gnueabihf-elfedit*    arm-linux-gnueabihf-gcc-nm*      arm-linux-gnueabihf-gfortran*  arm-linux-gnueabihf-objcopy*  arm-linux-gnueabihf-strings*  pylint*
arm-linux-gnueabihf-as*         arm-linux-gnueabihf-g++*        arm-linux-gnueabihf-gcc-ranlib*  arm-linux-gnueabihf-gprof*     arm-linux-gnueabihf-objdump*  arm-linux-gnueabihf-strip*    pyreverse*
arm-linux-gnueabihf-c++*        arm-linux-gnueabihf-gcc*        arm-linux-gnueabihf-gcov*        arm-linux-gnueabihf-ld*        arm-linux-gnueabihf-ranlib*   epylint*                      runtest*
arm-linux-gnueabihf-c++filt*    arm-linux-gnueabihf-gcc-5.3.1*  arm-linux-gnueabihf-gcov-tool*   arm-linux-gnueabihf-ld.bfd*    arm-linux-gnueabihf-readelf*  gdbserver*                    symilar*

此路径已添加到$PATH.

但是,如果我去./arm-linux-gnueabihf/bin并且会去做ls,我将收到空目录。我可以克服这个错误,如果我将一些符号链接添加到这个目录:

ar -> ../../bin/arm-linux-gnueabihf-ar*
as -> ../../bin/arm-linux-gnueabihf-as*
gcc -> ../../bin/arm-linux-gnueabihf-gcc*
ranlib -> ../../bin/arm-linux-gnueabihf-ranlib*
strip -> ../../bin/arm-linux-gnueabihf-strip*
...

在此之后,我的汇编错误消失了,我可以成功地为 ARM-target 编译项目。但在此之后,我无法为我的工作站 x86 编译任何东西。

谁能解释一下我应该怎么做才能成功编译以及ARM和x86?

UPD:我有 ARM 的 Makefile:

CROSS_COMPILE = arm-linux-gnueabihf-
CC            = $(CROSS_COMPILE)gcc
AS            = $(CROSS_COMPILE)as

INCLUDES      = -I./
SRC           = main.c
TARGET        = my-arm-target

all: $(SRC)
    $(CC) $(INCLUDES) -o $(TARGET)

和 x86 的相同文件,但没有CROSS_COMPILE变量:

CC            = gcc
AS            = as

INCLUDES      = -I./
SRC           = main.c
TARGET        = my-x86-target

all: $(SRC)
    $(CC) $(INCLUDES) -o $(TARGET)
software-installation compiling gcc arm cross-compilation
  • 1 个回答
  • 4840 Views
Martin Hope
psiphi75
Asked: 2018-08-04 02:01:35 +0800 CST

交叉编译 armhf 并安装静态库

  • 5

我已经设置了一个交叉编译的 docker 实例。简而言之,我开始设置

apt-get update
apt-get install binutils-multiarch

dpkg --add-architecture armhf
# Manually add correct armhf repositories to /etc/apt/sources.list
apt-get update
apt-get install libudev-dev:armhf

在这最后一步中,我收到以下错误:

The following packages have unmet dependencies:
libudev-dev:armhf : Depends: libacl1:armhf (>= 2.2.51-8) but it is not going to be installed
                    Depends: libblkid1:armhf (>= 2.19.1) but it is not going to be installed
                    Depends: libc6:armhf (>= 2.17) but it is not going to be installed
                    Depends: libgcc1:armhf (>= 1:3.5) but it is not going to be installed
                    Depends: libkmod2:armhf (>= 5~) but it is not going to be installed
                    Depends: libselinux1:armhf (>= 2.0.65) but it is not going to be installed
                    Depends: libudev1:armhf (= 229-4ubuntu4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

手动安装这些不是一个选项,因为libc6:armhf与当前安装的 amd64 libc6 冲突并且最终会覆盖这个包。我只想设置libudev:armhf包以便我可以链接到它。

/etc/apt/sources.list:

deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial main restricted
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted

deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted

deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial-updates universe

deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security main restricted
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security multiverse

运行apt-cache policy libudev-dev:{amd64,armhf}输出以下内容:

libudev-dev:
  Installed: (none)
  Candidate: 229-4ubuntu21.4
  Version table:
     229-4ubuntu21.4 500
        500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
     229-4ubuntu21.1 500
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
     229-4ubuntu4 500
        500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libudev-dev:armhf:
  Installed: (none)
  Candidate: 229-4ubuntu4
  Version table:
     229-4ubuntu4 500
        500 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf Packages
compiling arm cross-compilation
  • 1 个回答
  • 6668 Views
Martin Hope
Marc43
Asked: 2018-07-24 01:56:45 +0800 CST

在amd64架构机器上安装Python2.7和3个arm头

  • 2

我一直在苦苦挣扎,因为我想交叉编译一个需要 Python 编译的应用程序。以防万一您好奇,当它转到 pyconfig.h 时,它会尝试包含以下文件:

arm-linux-gnueabihf/python2.7/pyconfig.h

不幸的是,这不存在。然后,我想安装 python 头文件,所以我做了以下操作:

sudo dpkg --add-architecture armhf
sudo apt-get update

我得到以下输出,

Hit:2 http://ports.ubuntu.com/ubuntu-ports xenial InRelease                
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]             
Get:4 http://ports.ubuntu.com/ubuntu-ports xenial-security InRelease [107 kB]          
Hit:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease                      
Get:3 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]                       
Get:7 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [84.1 kB]     
Get:8 http://ports.ubuntu.com/ubuntu-ports xenial-security/main armhf Packages [514 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [668 kB]  
Get:10 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages [587 kB]   
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]               
Ign:11 http://archive.ubuntu.com/ubuntu xenial-backports/main armhf Packages           
Ign:12 http://archive.ubuntu.com/ubuntu xenial-backports/universe armhf Packages       
Get:13 http://ports.ubuntu.com/ubuntu-ports xenial-security/restricted armhf Packages [8480 B]
Get:14 http://ports.ubuntu.com/ubuntu-ports xenial-security/universe armhf Packages [375 kB]
Get:15 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB]
Get:16 http://security.ubuntu.com/ubuntu xenial-security/restricted i386 Packages [12.7 kB]
Get:17 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [455 kB]
Get:18 http://security.ubuntu.com/ubuntu xenial-security/universe i386 Packages [385 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]              
Get:20 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]    
Ign:21 http://archive.ubuntu.com/ubuntu xenial/main armhf Packages                     
Get:22 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]     
Ign:23 http://archive.ubuntu.com/ubuntu xenial/restricted armhf Packages               
Get:24 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3738 B]
Ign:25 http://security.ubuntu.com/ubuntu xenial-security/multiverse armhf Packages
Ign:25 http://security.ubuntu.com/ubuntu xenial-security/multiverse armhf Packages
Ign:25 http://security.ubuntu.com/ubuntu xenial-security/multiverse armhf Packages
Get:26 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Err:25 http://security.ubuntu.com/ubuntu xenial-security/multiverse armhf Packages 
  404  Not Found [IP: 91.189.88.152 80]
Get:27 http://archive.ubuntu.com/ubuntu xenial/universe i386 Packages [9804 kB]
Get:28 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Ign:29 http://archive.ubuntu.com/ubuntu xenial/multiverse armhf Packages
Ign:11 http://archive.ubuntu.com/ubuntu xenial-backports/main armhf Packages
Ign:12 http://archive.ubuntu.com/ubuntu xenial-backports/universe armhf Packages
Get:30 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [261 kB]
Get:31 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [1046 kB]
Ign:32 http://archive.ubuntu.com/ubuntu xenial-updates/main armhf Packages
Get:33 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.1 kB]
Ign:34 http://archive.ubuntu.com/ubuntu xenial-updates/restricted armhf Packages
Get:35 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [829 kB]
Ign:36 http://archive.ubuntu.com/ubuntu xenial-updates/universe armhf Packages
Get:37 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [18.8 kB]
Ign:38 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse armhf Packages
Ign:21 http://archive.ubuntu.com/ubuntu xenial/main armhf Packages
Ign:23 http://archive.ubuntu.com/ubuntu xenial/restricted armhf Packages
Ign:29 http://archive.ubuntu.com/ubuntu xenial/multiverse armhf Packages
Ign:11 http://archive.ubuntu.com/ubuntu xenial-backports/main armhf Packages
Ign:12 http://archive.ubuntu.com/ubuntu xenial-backports/universe armhf Packages
Ign:32 http://archive.ubuntu.com/ubuntu xenial-updates/main armhf Packages
Ign:34 http://archive.ubuntu.com/ubuntu xenial-updates/restricted armhf Packages
Ign:36 http://archive.ubuntu.com/ubuntu xenial-updates/universe armhf Packages
Ign:38 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse armhf Packages
Ign:21 http://archive.ubuntu.com/ubuntu xenial/main armhf Packages
Ign:23 http://archive.ubuntu.com/ubuntu xenial/restricted armhf Packages
Ign:29 http://archive.ubuntu.com/ubuntu xenial/multiverse armhf Packages
Err:11 http://archive.ubuntu.com/ubuntu xenial-backports/main armhf Packages
  404  Not Found [IP: 91.189.88.149 80]
Ign:12 http://archive.ubuntu.com/ubuntu xenial-backports/universe armhf Packages
Ign:32 http://archive.ubuntu.com/ubuntu xenial-updates/main armhf Packages
Ign:34 http://archive.ubuntu.com/ubuntu xenial-updates/restricted armhf Packages
Ign:36 http://archive.ubuntu.com/ubuntu xenial-updates/universe armhf Packages
Ign:38 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse armhf Packages
Err:21 http://archive.ubuntu.com/ubuntu xenial/main armhf Packages
  404  Not Found [IP: 91.189.88.149 80]
Ign:23 http://archive.ubuntu.com/ubuntu xenial/restricted armhf Packages
Ign:29 http://archive.ubuntu.com/ubuntu xenial/multiverse armhf Packages
Err:32 http://archive.ubuntu.com/ubuntu xenial-updates/main armhf Packages
  404  Not Found [IP: 91.189.88.149 80]
Ign:34 http://archive.ubuntu.com/ubuntu xenial-updates/restricted armhf Packages
Ign:36 http://archive.ubuntu.com/ubuntu xenial-updates/universe armhf Packages
Ign:38 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse armhf Packages
Fetched 2452 kB in 2s (1020 kB/s)
Reading package lists... Done
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/main/binary-armhf/Packages  404  Not Found [IP: 91.189.88.149 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/multiverse/binary-armhf/Packages  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/main/binary-armhf/Packages  404  Not Found [IP: 91.189.88.149 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/binary-armhf/Packages  404  Not Found [IP: 91.189.88.149 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

我在互联网上搜索,很多人说解决方案是在 /etc/apt/sources.list 中区分哪些存储库用于 armhf 架构,哪些存储库用于 amd64、i386。这根本不起作用(我也不知道我做得好不好,我对sources.list不太了解),当我执行这个命令时:

sudo apt-get install libpython2.7-dev:armhf

我得到:

    The following packages have unmet dependencies:
 libpython2.7-dev:armhf : Depends: libpython2.7-stdlib:armhf (= 2.7.12-1ubuntu0~16.04.2) but it is not going to be installed
                          Depends: libpython2.7:armhf (= 2.7.12-1ubuntu0~16.04.2) but it is not going to be installed
                          Depends: libexpat1-dev:armhf but it is not going to be installed
                          Recommends: libc6-dev:armhf but it is not going to be installed or
                                      libc-dev:armhf
E: Unable to correct problems, you have held broken packages

你知道我在哪一步搞砸了吗?我不确定,我会感谢你的帮助,谢谢。

apt software-sources arm cross-compilation linux-headers
  • 2 个回答
  • 1826 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve