linux 交叉编译opencv,c – 交叉编译openCV应用程序

大家好我正在为ARM做一个c应用程序.我有一个应用程序原型,我用交叉编译编译,它在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应用程序时没有.

我试着像这样编译:

arm-linux-g++ -c IPCamera.cpp `pkg-config opencv --libs --cflags`

但结果是一样的,但如果我这样做:

g++ -c IPCamera.cpp `pkg-config opencv --libs --cflags`

有用.所以我猜这是一个路径问题,但我不知道如何解决它.

有人可以帮帮我吗?

感谢大伙们

您好dennisfen这是mi文件的内容:

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}")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值