OpenCV 4.x+ requires enabled C++11 support compilation darknet fatal error

Well, There is no need to Un-install and Re-Install OpenCV Just add -std=c++11 in your compile line . Say your File is main, and you want the object file to be output .

g++ -std=c++11 main.cpp -o output `pkg-config --cflags --libs opencv`

And to view the output , type ->

./output

No, you don't set that c++11 flag, the cmake script is checking that, and that error is coming from here. That means most likely you're using an old gcc version. Test that with this g++ -dM -E -x c++ -std=c++11 /dev/null | grep plus and you should see #define __cplusplus 201103L, if not then need to install a newer version of gcc.


I've resolved the problem.

Uninstall opencv completely.

Download OpenCV Release 3.4.0 https://github.com/opencv/opencv/releases/tag/3.4.0 and not 3.4.1

With Cmake-gui (or not), ENABLE_CXX11 = 1

Recompile make -j4, install make install, sudo ldconfig and finally it works !

Conclusion : Never use the last version of anything