为mips处理器交叉编译opencv

时间:2015-06-03 18:18:23

标签: opencv mips cross-compiling axis

我正在尝试为嵌入式轴相机创建一个具有MIPS处理器的应用程序。我在我的项目中使用opencv。现在,在运行create-package.sh mipsisa32r2el后,我收到错误,它正在跳过不兼容的库,但找不到库。我想我应该为MIPS处理器交叉编译opencv,但我不知道我该怎么做。我已经检查过opencv文档,但我没有找到MIPS处理器的交叉编译。

2 个答案:

答案 0 :(得分:1)

从您的评论中看来,您的编译脚本已经在使用针对MIPS交叉编译的gcc(mipsisa32r2el-axis-linux-gnu-gcc看起来像来自Axis相机的工具链),如果您没有那个gcc (可能是脚本引用它但你没有它),你需要用BuildrootCrosstool-NG之类的东西建立一个mips32el工具链,这不是太难(和可以在工具链构建脚本中选择缺少的库。)

这里主要有两个问题,与你没有所有必需的依赖项/库有关:

  1. 某些库不兼容:工具链的gcc无法找到所需的库,并且它正在尝试使用主机上存在的库

  2. 有些库完全缺失:工具链的gcc无法在任何地方找到该库

  3. 要解决这些问题,每次编译脚本找不到库时,请构建它,并将生成的.so放在LD_LIBRARY_PATH的某个目录中。为每个缺少/不兼容的库执行此操作。 这将是一个漫长的过程。

答案 1 :(得分:1)

通过更改arm-gnueabi.toolchain.cmak以使用MIPS编译器,我找到了一种更简单的方法来编译mips处理器的opencv代码 这是改变的cmake:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR mips)

set(GCC_COMPILER_VERSION "4.6" CACHE STRING "GCC Compiler version")

set(FLOAT_ABI_SUFFIX "")
if (NOT SOFTFP)
  set(FLOAT_ABI_SUFFIX "hf")
endif()

#find_program(CMAKE_C_COMPILER NAMES mipsisa32r2el-axis-linux-        gnu${FLOAT_ABI_SUFFIX}-gcc${GCC_COMPILER_VERSION})
#find_program(CMAKE_CXX_COMPILER NAMES mipsisa32r2el-axis-linux-    gnu${FLOAT_ABI_SUFFIX}-g++${GCC_COMPILER_VERSION})
set(CMAKE_C_COMPILER /usr/local/mipsisa32r2el/r12/bin/mipsisa32r2el-axis-  linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /usr/local/mipsisa32r2el/r12/bin/mipsisa32r2el-axis-linux-gnu-g++) 
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}  -fdata-sections -Wa,--noexecstack -  fsigned-char ")
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}  -fdata-sections -Wa,--noexecstack -fsigned-char ")

set(CMAKE_SHARED_LINKER_FLAGS "-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,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS    "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_EXE_LINKER_FLAGS}")

if(USE_NEON)
  message(WARNING "You use obsolete variable USE_NEON to enable NEON    instruction set. Use -DENABLE_NEON=ON instead." )
  set(ENABLE_NEON TRUE)
elseif(USE_VFPV3)
  message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." )
  set(ENABLE_VFPV3 TRUE)
endif()

set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${MIPS_LINUX_SYSROOT})

if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR})
    set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH}     ${CUDA_TOOLKIT_ROOT_DIR})
endif()

set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added  when using shared libraries." )
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)

# macro to find programs on the host OS
macro( find_host_program )
 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
 if( CMAKE_HOST_WIN32 )
  SET( WIN32 1 )
  SET( UNIX )
 elseif( CMAKE_HOST_APPLE )
  SET( APPLE 1 )
  SET( UNIX )
 endif()
 find_program( ${ARGN} )
 SET( WIN32 )
 SET( APPLE )
 SET( UNIX 1 )
 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro()

# macro to find packages on the host OS
macro( find_host_package )
 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
 if( CMAKE_HOST_WIN32 )
  SET( WIN32 1 )
  SET( UNIX )
 elseif( CMAKE_HOST_APPLE )
  SET( APPLE 1 )
  SET( UNIX )
 endif()
 find_package( ${ARGN} )
SET( WIN32 )
SET( APPLE )
 SET( UNIX 1 )
 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro()

通过我在这个cmake中我创建了opencv的静态库