Darknet_ros Install Issue, OpenCV 4.x+ requires enabled C++11 error

asked 2020-12-26 04:45:50 -0500

tdam2112 gravatar image

updated 2021-01-02 04:05:56 -0500

Hello there, I'm trying to install darknet_ros on the Jetson Xavier running ubuntu 18.04 with JetPack 4.4.1, I couldn't find any guide specific to jetson platforms so I used the installation steps on the main github page for the project.

I'm not able to do the catkin_make command successfully, below is the last part of the catkin_make output:

[ 68%] Building C object darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/__/darknet/src/activation_layer.c.o
[ 69%] Building C object darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/src/image_interface.c.o
[ 71%] Built target rtabmap_sync
[ 71%] Building C object darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/__/darknet/src/activations.c.o
[ 72%] Built target rtabmap_wifi_signal_pub
[ 75%] Built target rtabmap_rviz_plugins
[ 75%] Built target rtabmap_wifi_signal_sub
[ 75%] Building C object darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/__/darknet/src/image.c.o
[ 76%] Built target rtabmap_map_assembler
[ 77%] Building C object darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/__/darknet/src/avgpool_layer.c.o
[ 77%] Building C object darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/__/darknet/src/layer.c.o
[ 78%] Built target rtabmapviz
[ 84%] Built target rtabmap_plugins
[ 84%] Building C object darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/__/darknet/src/batchnorm_layer.c.o
[ 84%] Building C object darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/__/darknet/src/list.c.o
In file included from /usr/include/opencv4/opencv2/core/types_c.h:82:0,
                 from /usr/include/opencv4/opencv2/core/core_c.h:48,
                 from /usr/include/opencv4/opencv2/highgui/highgui_c.h:45,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/include/darknet.h:25,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/src/box.h:3,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/src/image.h:9,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet_ros/include/darknet_ros/image_interface.h:12,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet_ros/src/image_interface.c:9:
/usr/include/opencv4/opencv2/core/cvdef.h:690:4: error: #error "OpenCV 4.x+ requires enabled C++11 support"
 #  error "OpenCV 4.x+ requires enabled C++11 support"
    ^~~~~
In file included from /usr/include/opencv4/opencv2/core/types_c.h:82:0,
                 from /usr/include/opencv4/opencv2/core/core_c.h:48,
                 from /usr/include/opencv4/opencv2/highgui/highgui_c.h:45,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/include/darknet.h:25,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/src/box.h:3,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/src/image.h:9,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/src/avgpool_layer.h:4,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/src/avgpool_layer.c:1:
/usr/include/opencv4/opencv2/core/cvdef.h:690:4: error: #error "OpenCV 4.x+ requires enabled C++11 support"
 #  error "OpenCV 4.x+ requires enabled C++11 support"
    ^~~~~
compilation terminated due to -Wfatal-errors.
compilation terminated due to -Wfatal-errors.
In file included from /usr/include/opencv4/opencv2/core/types_c.h:82:0,
                 from /usr/include/opencv4/opencv2/core/core_c.h:48,
                 from /usr/include/opencv4/opencv2/highgui/highgui_c.h:45,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/include/darknet.h:25,
                 from /home/nvidiaagx/catkin_ws/src/darknet_ros/darknet/src/activations ...
(more)
edit retag flag offensive close merge delete

Comments

i think the way to add c++11 at compile time is adding the following line adt CmakeLists.txt

add_definitions(-std=c++11)
Solrac3589 gravatar image Solrac3589  ( 2021-01-04 01:28:18 -0500 )edit

Hey, I tried adding that line to the top of the CmakeLists.txt, but I'm getting the same error with some extra warnings :

cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C
tdam2112 gravatar image tdam2112  ( 2021-01-04 06:41:05 -0500 )edit

Seems like for some reason Cmake is only reading C. Could you show us your file?

Solrac3589 gravatar image Solrac3589  ( 2021-01-05 06:30:49 -0500 )edit

@tdam2112 were you able to find a solution to it?

Anshul gravatar image Anshul  ( 2021-02-22 05:54:36 -0500 )edit