简体   繁体   English

使用依赖项进行交叉编译:如何在主机上获取目标依赖项?

[英]cross-compile with dependencies: how to get target dependencies on host?

I've been struggling to cross-compile OpenCV for arm on my x64 dual Xeon running Ubuntu 16.04 我一直在努力在运行Ubuntu 16.04的 x64双Xeon上交叉编译OpenCV for arm

I understand how cross-compiler work, and it's fine compiling a simple project, but OpenCV has lots of dependencies. 我理解交叉编译器是如何工作的,并且很好地编译了一个简单的项目,但OpenCV有很多依赖项。

I do not understand how to load these dependencies (headers only?) on the host used to cross-compile 我不明白如何在用于交叉编译的主机上加载这些依赖项(仅限标题?)

I have tried 我努力了

dpkg --add-architecture armhf

and I have tried adding the urls in the sources.list to install the dependencies. 我已经尝试在sources.list添加url来安装依赖项。

I have tried installing dependencies with the :armhf suffix but these dependencies tend to have dependencies themselves and I end up with error of the form: cannot install 我尝试使用:armhf后缀安装依赖项,但这些依赖项本身往往具有依赖项,我最终会:armhf表单错误: cannot install

I tried also to use 我也尝试过使用

apt-get build-dep --download-only <dependency>:armhf

but that just didn't seem to help. 但这似乎没有帮助。

So, first I'd like to understand: 所以,首先我想了解:

  • Do I need the dependent libraries with the source code, or just the headers? 我是否需要包含源代码的依赖库,或者只需要标题? I would think I just need the headers, but I'm confused now. 我想我只需要标题,但我现在很困惑。

  • What exactly do I need to do to get the dependencies on the host, in order to cross compile? 为了交叉编译,我到底需要做些什么才能获得主机上的依赖?

Sorry if it's vague; 对不起,如果它含糊不清; I'm just not sure where to look for this. 我只是不确定在哪里寻找这个。 Every tutorial I see on cross-compiling leaves dependencies aside, and the OpenCV project explanation on cross-compiling assumes the reader already knows all this... 我在交叉编译时看到的每个教程都将依赖关系放在一边,而关于交叉编译的OpenCV项目解释假设读者已经知道所有这些......

Thanks for help 感谢帮助

EDIT 编辑

I added my solution below, but I don't find this ideal since it requires to install everything on the target first. 我在下面添加了我的解决方案,但我发现这并不理想,因为它需要先在目标上安装所有内容。 Obviously, the dependencies are needed on the target anyways, but there is no need for all the dev libraries and headers for runtime 显然,无论如何都需要目标上的依赖项,但是不需要运行时的所有dev库和头文件

So I'm still looking for a better solution 所以我仍在寻找更好的解决方案

I managed to cross-compile, but it was a little painful. 我设法交叉编译,但这有点痛苦。

The only way I found so far to get the dependencies on the compiling host, was to simply copy the files from the target where I installed them. 到目前为止,我发现获取编译主机依赖关系的唯一方法是简单地从我安装它们的目标中复制文件。

The folders needed are mostly 所需的文件夹大多是

  • /usr (especially usr/include , /usr/lib and /usr/bin ) /usr (特别是usr/include/usr/lib/usr/bin
  • /lib
  • /opt (if you had any special library setup there) /opt (如果你有任何特殊的库设置)

You can tar those folders and copy them over to the host, or use rsync. 您可以对这些文件夹进行tar并将其复制到主机,或使用rsync。

After that, you have to make sure to configure the path with cmake . 之后,您必须确保使用cmake配置路径。

I copied stuff to a folder called sysroot-chip at the same level as opencv and my build dir is also at the same level (outside of opencv) 我将东西复制到一个名为sysroot-chip的文件夹,与opencv处于同一级别,我的构建目录也处于同一级别(opencv之外)

and added the following flags to cmake : 并将以下标志添加到cmake

-D INCLUDE_DIRECTORIES=../sysroot-chip/usr/lib \
-D INCLUDE_DIRECTORIES=../sysroot-chip/usr/bin \
-D INCLUDE_DIRECTORIES=../sysroot-chip/opt/lib \
-D INCLUDE_DIRECTORIES=../sysroot-chip/lib \
-D PYTHON2_INCLUDE_PATH=../sysroot-chip/usr/include/python2.7 \
-D PYTHON2_LIBRARIES=../sysroot-chip/usr/lib/python2.7 \
-D PYTHON2_NUMPY_INCLUDE_DIRS=../sysroot-chip/usr/lib/python2.7/dist-packages \
-D PYTHON3_INCLUDE_PATH=../sysroot-chip/usr/include/python3.4 \
-D PYTHON3_LIBRARIES=../sysroot-chip/usr/lib/python3.4 \
-D PYTHON3_NUMPY_INCLUDE_DIRS=../sysroot-chip//usr/lib/python3.4/dist-packages \

along with the cross compiling toolchain flag: 以及交叉编译工具链标志:

-D CMAKE_TOOLCHAIN_FILE=../opencv-3.1.0/platforms/linux/arm-gnueabi.toolchain.cmaketoolchain.cmake \

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

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