我跟着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教程,但找不到我什麼正在做在這裏。