交叉编译openCV应用程序
Cross compilation openCV application
大家好,我正在用c++为ARM做一个应用程序。我有一个应用程序原型,我用交叉编译编译,它在ARM上工作得很好。我所做的是:
首先我得到。o文件,像这样
arm-linux-g++ -c PrototipoTRU.cpp
然后我得到。exe像这样(我的应用程序使用线程)
arm-linux-g++ PrototipoTRU.o -o tru2 -pthread
一切都很完美
我的问题是当我试图编译使用OpenCV的。cpp文件时。我试过了:
首先我试着得到。o:
arm-linux-g++ -c camera.cpp
不行,我得到这样的输出:
IPCamera.cpp:5:30: error: opencv2/opencv.hpp: No such file or directory
IPCamera.cpp:6:39: error: opencv2/highgui/highgui.hpp: No such file or directory
IPCamera.cpp:7:39: error: opencv2/imgproc/imgproc.hpp: No such file or directory
IPCamera.cpp:11:22: error: X11/Xlib.h: No such file or directory
IPCamera.cpp:16: error: 'cv' is not a namespace-name
IPCamera.cpp:16: error: expected namespace-name before ';' token
IPCamera.cpp: In function 'int main(int, char**)':
IPCamera.cpp:46: error: 'cv' has not been declared
IPCamera.cpp:46: error: expected ';' before 'cap'
IPCamera.cpp:52: error: 'Display' was not declared in this scope
IPCamera.cpp:52: error: 'disp' was not declared in this scope
IPCamera.cpp:52: error: 'XOpenDisplay' was not declared in this scope
IPCamera.cpp:53: error: 'Screen' was not declared in this scope
IPCamera.cpp:53: error: 'scrn' was not declared in this scope
IPCamera.cpp:53: error: 'DefaultScreenOfDisplay' was not declared in this scope
IPCamera.cpp:63: error: 'cv' has not been declared
IPCamera.cpp:63: error: expected ';' before 'frame'
IPCamera.cpp:66: error: 'cv' has not been declared
IPCamera.cpp:66: error: 'CV_WINDOW_NORMAL' was not declared in this scope
IPCamera.cpp:68: error: 'cvMoveWindow' was not declared in this scope
IPCamera.cpp:73: error: 'CV_WND_PROP_FULLSCREEN' was not declared in this scope
IPCamera.cpp:73: error: 'CV_WINDOW_FULLSCREEN' was not declared in this scope
IPCamera.cpp:73: error: 'cvSetWindowProperty' was not declared in this scope
IPCamera.cpp:79: error: 'cap' was not declared in this scope
IPCamera.cpp:82: error: 'frame' was not declared in this scope
IPCamera.cpp:89: error: 'cv' has not been declared
IPCamera.cpp:92: error: 'cv' has not been declared
所以似乎有一些问题与链接,但如果这样做:
g++ -c IPCamera.cpp
我得到了。o文件,但很明显,当我得到。exe时,它在ARM中不起作用。我不明白的是为什么如果我编译一个没有opencv的应用程序,就像第一个例子一样,arm-linux-g++正常工作,当我试图编译opencv应用程序no.
我试着编译也像这样:
arm-linux-g++ -c IPCamera.cpp `pkg-config opencv --libs --cflags`
但是,如果我这样做,结果是相同的:
g++ -c IPCamera.cpp `pkg-config opencv --libs --cflags`
它的工作原理。所以我猜这是一个路径问题,但我不知道如何解决它。
有人能帮帮我吗??谢谢大家
嗨,dennisfen,这是我文件的内容:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(GCC_COMPILER_VERSION "4.6" CACHE STRING "GCC Compiler version")
set(FLOAT_ABI_SUFFIX "")
if (NOT SOFTFP)
set(FLOAT_ABI_SUFFIX "hf")
endif()
set(CMAKE_C_COMPILER arm-linux-
gnueabi${FLOAT_ABI_SUFFIX}-gcc-${GCC_COMPILER_VERSION})
set(CMAKE_CXX_COMPILER arm-linux-
gnueabi${FLOAT_ABI_SUFFIX}-g++-${GCC_COMPILER_VERSION})
set(ARM_LINUX_SYSROOT /usr/arm-linux-gnueabi${FLOAT_ABI_SUFFIX} CACHE PATH "ARM cross
compilation system root")
set(CMAKE_CXX_FLAGS "" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS "" CACHE STRING "c flags")
set(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags")
set(CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "executable linker
flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -fdata-sections -Wa,--noexecstack
-fsigned-char -Wno-psabi")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthumb -fdata-sections -Wa,--noexecstack
-fsigned-char -Wno-psabi")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-
sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-
sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-
sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_EXE_LINKER_FLAGS}")
似乎您需要设置包含路径到您的交叉OpenCV安装:
arm-linux-g++ -I/path/to/opencv/include IPCamera.cpp -o tru2
当你调用pkg-config时,它会为你的主机系统报告设置,而不是为你的手臂交叉工具链。
正如@dennisfen建议的那样,您可能需要设置包含路径以及与您正在使用的库的交叉OpenCV库路径,如下所示:
arm-linux-g++ -I/path/to/opencv/include -L/path/to/library IPCamera.cpp -o tru2 -lopencv_core -pthread
相关文章:
- 如何在 docker 中使用静态 opencv 库编译 c++ 应用程序
- 如何提高 OpenCV 实时检测器应用程序的帧率?
- 在Linux/Ubuntu中编译openCV应用程序时,如何解决未定义的引用cv:..?
- Opencv在2013年第5季度不起作用.应用程序总是在窗口中崩溃
- "OpenCV Error: The function/feature is not implemented"安卓应用程序
- 如何将此项目更改为 OpenCV 实时人脸检测应用程序?
- 如何在 Unity Android 应用程序中的 OpenCV 中使用 ARCore 相机图像
- Android OpenCV 应用程序的内存问题
- WINDOWS环境下的c++opencv应用程序的低延迟视频流
- IPP如何改进OpenCV应用程序?我该如何整合它
- 我可以将OpenCV的Release配置与我的应用程序的Debug配置一起使用吗
- 如何将OpenCV的输出显示或流式传输到HTML页面或其他一些客户端应用程序
- 在Android Java应用程序中使用OpenCV Mat.OpenCV Mat出现NoClassDefFound错误
- 在 Eclipse 中使用 JNI 构建 OpenCV 应用程序
- OPENCV:image_proc中的 PCA 应用程序错误
- 在c#应用程序中调用opencv c++代码
- 将OpenCV .dll文件添加到NetBeans C QT应用程序
- Ubuntu 上的 Qt+OpenCV 无法运行/调试:无法启动应用程序
- 由OpenCV 2.4.6创建的AVI文件在应用程序退出时并不总是有效
- 在我的Nexus 4上使用openCV和JNI的Android应用程序中的错误