用cmake与OpenCV对ARM进行交叉编译
I am trying to crosscompile my application, written in C++ and using OpenCV for BeagleBone ARM-based board. The target OS is Ubuntu 13.10, the host OS is Ubuntu 12.04 and I can build the app successfully on the both systems using native compiler. However, when I crosscompile using arm cross compiler from Ubuntu repository, I get an error about missing standard header file (bits/stdlib-float.h). Here is a small example to show the same problem (arm_root directory contains the target environment).
我正在尝试交叉编译我的应用程序,用c++编写,并使用OpenCV编写基于BeagleBone的板。目标操作系统是Ubuntu 13.10,主机操作系统是Ubuntu 12.04,我可以使用本机编译器在两个系统上成功构建应用。然而,当我使用来自Ubuntu存储库的arm交叉编译器进行交叉编译时,我得到了一个关于缺少标准头文件(bit /stdl -float.h)的错误。下面是一个显示相同问题的小示例(arm_root目录包含目标环境)。
src/cross.cpp:
src / cross.cpp:
#include <opencv2/opencv.hpp>
int main()
{
cv::Mat m(10, 10, CV_8UC1);
return 0;
}
CMakeLists.txt:
CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
find_package(OpenCV REQUIRED)
add_executable(cross src/cross.cpp)
target_link_libraries(cross ${OpenCV_LIBS})
arm_toolchain.cmake (The idea is to link the app to the standard C++ library in the host crosscompiler environment, but link to the OpenCV in the target environment. I am not sure whether this is a right choice):
arm_toolchain。cmake(其想法是将应用程序链接到主机交叉编译环境中的标准c++库,而在目标环境中链接到OpenCV。我不确定这是否是一个正确的选择):
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)
set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf /home/alex/arm_root)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
cmake -DCMAKE_TOOLCHAIN_FILE=../arm_toolchain.cmake .. && make:
cmake -DCMAKE_TOOLCHAIN_FILE = . . / arm_toolchain。cmake . .& &:
[100%] Building CXX object CMakeFiles/cross.dir/src/cross.cpp.o
In file included from /home/alex/arm_root/usr/include/opencv2/core/types_c.h:56:0,
from /home/alex/arm_root/usr/include/opencv2/core/core_c.h:47,
from /home/alex/arm_root/usr/include/opencv2/opencv.hpp:46,
from /home/alex/sandbox/cmake/cross/src/cross.cpp:1:
/home/alex/arm_root/usr/include/stdlib.h:951:31: fatal error: bits/stdlib-float.h: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/cross.dir/src/cross.cpp.o] Error 1
make[1]: *** [CMakeFiles/cross.dir/all] Error 2
make: *** [all] Error 2
2 个解决方案
#1
1
Does the file /home/alex/arm_root/usr/include/bits/stdlib-float.h
exist? Make sure you are using the correct include directory. In some toolchains there are multiple include directories. Try to add the following line to your toolchain definition file:
/home/alex/arm_root/usr/include/bits/stdlib-float的文件。h存在吗?确保您使用的是正确的include目录。在一些工具链中有多个包含目录。尝试在您的工具链定义文件中添加以下行:
set(CMAKE_CXX_FLAGS "-isystem /home/alex/arm_root/usr/include")
or whatever directory the required include files are in. This will make sure the compiler uses the correct path for the standard headers.
或者任何需要包含文件的目录。这将确保编译器对标准头使用正确的路径。
更多相关文章
- linux使用技巧,返回上一次目录
- cp dir recursivly不包括2个子目录
- Linux中/proc目录下文件详解之(二)
- linux /usr /var /etc 目录
- debain 系统 ll 命令无法使用.目录和文件没有颜色区分解决之道
- 通过排除其父文件夹为多个目录创建单个tar文件
- 解决useradd 用户后没有添加用户Home目录的情况,Linux改变文件或
- Linux 软件安装到 /usr,/usr/local/ 还是 /opt 目录区别
- MySQL——问题:mysql(5.7版本)目录下没有data文件夹