Siladittya
Siladittya

Reputation: 1205

Building Opencv using cmake giving errors involving c++11

I am facing problem with the cmake command while compiling opencv on Ubuntu 16.04. When I execute the cmake command, I get the error

CMake Error at CMakeLists.txt:11 (message): FATAL: In-source builds are not allowed. You should create a separate directory for build files.

I have extracted the opencv source file in a folder named opencv-3.3.1 Then I have followed all the processes mentioned in this site

https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/

I use the following commands :: cd opencv-3.3.1/ mkdir build/ cd build/ cmake -D CMA KE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.1/modules -D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python -D BUILD_EXAMPLES=ON ..

But I am getting this error!

What can be the possible problem?

The CMakeError.log shows

error "C++11 is not supported

I have tried adding set(CMAKE_CXX_FLAGS "-std=c++11") to the beginning of the CMakeLists.txt and also included the flag -DENABLE_CXX11=ON to the CMAKE command flags. But nothing seems to work.

Please help!!

Upvotes: 0

Views: 1497

Answers (2)

Wei Guo
Wei Guo

Reputation: 564

Maybe there is a file called CMakeCache.txt in your OpenCV root directory opencv-3.3.1.

Just remove it!

That's because someone have executed cmake . inside the root directory opencv-3.3.1 before.

Upvotes: 3

BHawk
BHawk

Reputation: 2472

Try adding:

add_definitions(-std=c++11)

to your cmakelists file.

Upvotes: 0

Related Questions