我跟着this tutorial试图创建一些OpenCV项目。 它在Windows和Visual Studio伟大的工作,但后来我试着用CMake的使用下面的CMakeLists.txt在我Ubunto虚拟机来运行它:用CMake编译OpenCV项目时出错
cmake_minimum_required(VERSION 2.8)
project(TrackObj)
find_package(OpenCV REQUIRED)
add_executable(TrackObj Source.cpp Fruit.cpp Fruit.h)
target_link_libraries(TrackObj ${OpenCV_LIBS})
当我运行cmake .
好像一切都很好:
[email protected]:~/Desktop/TrackObj$ cmake .
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vm/Desktop/TrackObj
但是当我运行make
我得到以下错误:
[email protected]:~/Desktop/TrackObj$ make
Scanning dependencies of target TrackObj
[ 50%] Building CXX object CMakeFiles/TrackObj.dir/Source.cpp.o
In file included from /usr/include/c++/4.8/thread:35:0,
from /home/vm/Desktop/TrackObj/Source.cpp:10:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
make[2]: *** [CMakeFiles/TrackObj.dir/Source.cpp.o] Error 1
make[1]: *** [CMakeFiles/TrackObj.dir/all] Error 2
make: *** [all] Error 2
我很新的CMake的,但我敢确定问题是事实我使用多个.cpp文件和我使用CMake的方式。原因是当我试图运行一个previews step in the tutorial,当这个项目只包含一个.cpp文件时,这一切都很好。
你可以看到源代码,没有工作here(与像去除#include <opencv\highgui.h> #include <opencv\cv.h>
和写作,而不是小的变化:。#include <opencv2/opencv.hpp>
和源代码,没有工作here用相同的微小变化除了,该项目包括非常简单Fruit.cpp和Fruit.h如视频描述。
我走过去的CMake的不那么友好official tutorial和更友好johnlamp和OpenCV教程,但找不到我什么正在做在这里。