opencv使用cmake进行交叉编译

时间:2017-07-14 07:05:02

标签: c++ opencv cmake

我正在尝试交叉编译一个使用openCV和Raspberry Pi的摄像头API的c ++项目,但是在编译成功完成后我遇到以下链接器错误: make [2]:没有规则来制作目标'/ 'agv_car'需要opt / vc / lib / libmmal_core.so'。停止。虽然.so文件位于搜索目录中的目录中(请参阅下面的cmake文件) 的CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)


INCLUDE_DIRECTORIES($ENV{HOME}/rpi/rootfs/opt/vc/include)
INCLUDE_DIRECTORIES($ENV{HOME}/rpi/rootfs/opt/vc/include/interface/vcos/pthreads)
INCLUDE_DIRECTORIES($ENV{HOME}/rpi/rootfs/opt/vc/include/interface/vmcs_host/linux)
INCLUDE_DIRECTORIES(/home/mihai/rpi/rootfs/opt/vc/lib)


find_package(OpenCV REQUIRED)
find_package(raspicam REQUIRED)

file(GLOB SOURCE_FILES  src/*.cpp)


add_executable(agv_car ${SOURCE_FILES})
target_link_libraries(agv_car  ${OpenCv_LIBS} ${raspicam_CV_LIBS})

这是工具链cmake文件:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)

# Specify the cross compiler
SET(CMAKE_C_COMPILER $ENV{HOME}/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER $ENV{HOME}/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /home/mihai/rpi/rootfs/usr/local/lib/cmake)


# Where is the target environment
SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/rpi/rootfs)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")

# Search for programs only in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Search for libraries and headers only in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

任何建议都会有所帮助,我花了一些时间试图弄清楚但没有任何成功。 “rpi / rootfs”是我从SD卡复制Raspberry Pi的根文件目录的位置。

修改  在做了更改后,Tsyvarev建议我收到以下错误:`

In file included from /home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/bits/locale_facets.h:39:0,
                 from /home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/bits/basic_ios.h:37,
                 from /home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/ios:44,
                 from /home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/istream:38,
                 from /home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/sstream:38,
                 from /home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/complex:45,
                 from /home/mihai/rpi/rootfs/usr/local/include/opencv2/core/cvstd.inl.hpp:48,
                 from /home/mihai/rpi/rootfs/usr/local/include/opencv2/core.hpp:3217,
                 from /home/mihai/rpi/rootfs/usr/local/include/opencv2/imgproc.hpp:46,
                 from /home/mihai/work/src/main.cpp:1:
/home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/cwctype:82:11: error: ‘::wctrans_t’ has not been declared
   using ::wctrans_t;
           ^
/home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/cwctype:104:11: error: ‘::wctrans’ has not been declared
   using ::wctrans;
           ^
In file included from /home/mihai/rpi/rootfs/usr/local/include/opencv2/imgproc/imgproc_c.h:46:0,
                 from /home/mihai/rpi/rootfs/usr/local/include/opencv2/imgproc.hpp:4698,
                 from /home/mihai/work/src/main.cpp:1:
/home/mihai/rpi/rootfs/usr/local/include/opencv2/imgproc/types_c.h: In constructor ‘CvMoments::CvMoments(const cv::Moments&)’:
/home/mihai/rpi/rootfs/usr/local/include/opencv2/imgproc/types_c.h:423:62: error: call of overloaded ‘sqrt(double&)’ is ambiguous
         inv_sqrt_m00 = am00 > DBL_EPSILON ? 1./std::sqrt(am00) : 0;
                                                              ^
/home/mihai/rpi/rootfs/usr/local/include/opencv2/imgproc/types_c.h:423:62: note: candidates are:
In file included from /home/mihai/rpi/rootfs/usr/local/include/opencv2/core/cvstd.hpp:65:0,
                 from /home/mihai/rpi/rootfs/usr/local/include/opencv2/core/base.hpp:58,
                 from /home/mihai/rpi/rootfs/usr/local/include/opencv2/core.hpp:54,
                 from /home/mihai/rpi/rootfs/usr/local/include/opencv2/imgproc.hpp:46,
                 from /home/mihai/work/src/main.cpp:1:
/home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/cmath:482:3: note: float std::sqrt(float)
   sqrt(float __x)
   ^
/home/mihai/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/cmath:486:3: note: long double std::sqrt(long double)
   sqrt(long double __x)
   ^
CMakeFiles/agv_car.dir/build.make:54: recipe for target 'CMakeFiles/agv_car.dir/src/main.cpp.o' failed
make[2]: *** [CMakeFiles/agv_car.dir/src/main.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/agv_car.dir/all' failed
make[1]: *** [CMakeFiles/agv_car.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

`

0 个答案:

没有答案