Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error "OpenCV 4.x+ requires enabled C++11 support" #13

Open
liang-grape opened this issue Jul 7, 2021 · 17 comments
Open

error "OpenCV 4.x+ requires enabled C++11 support" #13

liang-grape opened this issue Jul 7, 2021 · 17 comments

Comments

@liang-grape
Copy link

When I catkin_make,

the error "/usr/include/opencv4/opencv2/core/cvdef.h:690:4: error: #error "OpenCV 4.x+ requires enabled C++11 support" occurs. I have tried all ways I can search online, but I cannot solve the problem.

Could you give some advice?

Thank you

@fjlv520
Copy link

fjlv520 commented Jul 24, 2021

hello, I met the same issue, did u solve it?

@fjlv520
Copy link

fjlv520 commented Jul 26, 2021

Ok,I solve it. Modify the cvbridgeConfig.cmake file,change the SET_OPENCV_DIR to the path of opencv 3.x.x

@zeta0707
Copy link

zeta0707 commented Aug 8, 2021

Hi fjlv520,

I met same issue with Jetson Nano, image is Jetpack4.5.1.
OpenCV 4.1.1 is pre-installed here.
Do you install openCV3.x in parallel?

Thanks!

@fjlv520
Copy link

fjlv520 commented Aug 8, 2021

@zeta0707 Yes, I installed opencv3.4.1 additionally.

@zeta0707
Copy link

@fjlv520

I delete pre-installed opencv4.1.1, then installed opencv3.4.6 into /usr/local.
I also built successfully.

Thanks!

@iamrajee
Copy link

iamrajee commented Oct 4, 2021

same issue!

@iamrajee
Copy link

iamrajee commented Oct 4, 2021

I want to work with yolov4 with opencv4, leggedrobotics branch support opencv4 but not yolov4 and Tossy0423 branch support yolov4 but not opencv4.

@iamrajee
Copy link

iamrajee commented Oct 4, 2021

@fjlv520

I delete pre-installed opencv4.1.1, then installed opencv3.4.6 into /usr/local. I also built successfully.

Thanks!

Could you eloborate the steps. I install the opencv 3.4.1 using pip, however I couldn't locate it in /usr/include. Additionally I couldn't even locate "SET_OPENCV_DIR". Instead I found the include path as below
Screenshot from 2021-10-04 16-38-46

Am I doing something wrong? (I'm on noetic)
I'm new to opencv, sorry for asking a silly doubt, Thanks for the help!

@fettahyildizz
Copy link

4.1 addi

Could you eloborate the steps, please? I am having the same issue.

@iamrajee
Copy link

iamrajee commented Nov 12, 2021

@fettahyildizz I got it running by following the below steps. Just install OpenCV 3 and changed cvbridge opencv path.

@iamrajee
Copy link

iamrajee commented Nov 12, 2021

@fettahyildizz
Here are the detailed steps:

Installing OpenCV 3.4.6 (along with previous '4.5.3')
https://learnopencv.com/install-opencv3-on-ubuntu/

cd /usr/include/

  1. git clone https://github.com/opencv/opencv.git

  2. cd opencv

  3. git checkout 3.3.1

  4. cd ..

  5. git clone https://github.com/opencv/opencv_contrib.git

  6. cd opencv_contrib

  7. git checkout 3.3.1

  8. cd ..

  9. cd opencv

  10. mkdir build

  11. cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D INSTALL_C_EXAMPLES=ON \
      -D INSTALL_PYTHON_EXAMPLES=ON \
      -D WITH_TBB=ON \
      -D WITH_V4L=ON \
      -D WITH_QT=ON \
      -D WITH_OPENGL=ON \
      -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
      -D BUILD_EXAMPLES=ON ..
  1. find out number of CPU cores in your machine

  2. nproc
  3. substitute 4 by output of nproc

  4. make -j4
  5. sudo make install
  6. sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
  7. sudo ldconfig

Now lets check if we can import previous version of opencv i.e 4.5.3

python3

import cv2
cv2.version
⇒ Should output '4.5.3', if not and give the below error

ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.

Then run this:
sudo pip3 install opencv-python --upgrade --force-reinstall

Now, Lets change opencv version in cv_bridge
cd /opt/ros/noetic/share/cv_bridge/cmake
code cv_bridgeConfig.cmake
image

@fettahyildizz
Copy link

@iamrajee wow you're a life saver. Thanks a lot for detailed explanations. I will try it on monday.

@fettahyildizz
Copy link

@iamrajee I will be using this package on Ros-Melodic therefore, I will run it on Python 2.7. I am going to change every "pip3" command to "pip" while following your steps.

@tandrewsnz
Copy link

A bit late but I found an easier fix was using
sudo apt -y --allow-downgrades install libopencv-dev=3.2.0+dfsg-4ubuntu0.1 to force downgrade my opencv version to 3.2 from 4.1. as mentioned here

@iamrajee
Copy link

Is there any way to get it work with OpenCV 4.x itself, like by adding -std=c++11 somewhere in CMakeLists.txt as suggest here(1, 2). I tried adding below lines, but none of them helped.

add_definitions(-std=c++11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

What is the root problem here? Could somebody elaborate? Thank you!

@kyuhyong
Copy link

kyuhyong commented Sep 2, 2022

@iamrajee Did you solve the issue? I am having the same problem.
Installed opencv 3.4 on jetson nano.
Also running ros-melodic.

@kyuhyong
Copy link

After a while I revisited this issue and finally able to build and run on ROS noetic + CUDA 12.2 + opencv4+
You can checkout my forked version of darknet_ros as branch opencv4 and clone to your catkin workspace.
https://github.com/kyuhyong/yolov4-for-darknet_ros/tree/opencv4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants