OpenCV v3.3.1 ARM 交叉编译失败:找不到 CMAKE_CXX_COMPILER

OpenCV v3.3.1 Cross compilation for ARM Fails: No CMAKE_CXX_COMPILER could be found

我遵循了本教程,Cross compilation for ARM based Linux systems, in order to build Opencv version 3.3.1 using cmake for ARM based Linux system (Ubuntu Mate running on ODROID-XU4 Mini PC)。对于构建过程,我是 运行 Ubuntu Mate v 16.04.1 x86.

请注意,我已经尝试按照本教程 Opencv Installation in Linux 为我的 Intel x86 Ubuntu based 运行 机器构建相同版本的 Opencv,并且我做到了 成功。但是,当使用同一台机器为 ARM 构建它时,出现以下错误。

-- The CXX compiler identification is unknown
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:114 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:114 (project):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "/home/jhon/Programs/opencv-3.3.1/arm/CMakeFiles/CMakeOutput.log".
See also "/home/jhon/Programs/opencv-3.3.1/arm/CMakeFiles/CMakeError.log".

这是我生成此错误的命令行:

cmake -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/arm-gnueabi.toolchain.cmake ..

请注意,选项 -DCMAKE_TOOLCHAIN_FILE 告诉 cmake 为基于 ARM 的 Linux 系统构建 Opencv,当我尝试删除它时,我成功地结束了为我的 x86 机器构建 Opencv,没有任何错误。

提前致谢。

OpenCV 文档告诉只安装 C 交叉编译器(包 gcc-arm-linux-gnueabi),但实际上 OpenCV 需要 C++ 编译器也是。

所以还需要安装 g++-arm-linux-gnueabi 包。

我一直想知道为什么没有为 Opencv-Linux 预构建的二进制文件(我仍然不知道为什么)所以在这里我把我为 public 所做的工作从中受益它包含用于 Linux x86、x64 和 armv7hf(包括相应的 java 二进制文件)的 Opencv 3.3.1 预构建版本。

OpenCV Linux x86, x62 & armv7hf binaries