CMake Problems Jpeg Decode CPP error: redefinition of ‘struct v4l2_ctrl_h264_sps’ 195 | struct v4l2_ctrl_h264_sps

hi, i am currently trying to build a Ros2 node in cpp to use the hardware decoder of my jetson agx orin to decode jepg

i started with Article as example but now i am getting this error when building

i must use jetpack 5.1.2 and i work in a docker

[ 9%] Building CXX object CMakeFiles/test_jpeg.dir/NvSurfEncoder.cpp.o In file included from /usr/src/jetson_multimedia_api/include/NvBuffer.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:9: /usr/src/jetson_multimedia_api/include/v4l2_nv_extensions.h:304: warning: "V4L2_H264_DPB_ENTRY_FLAG_ACTIVE" redefined 304 | #define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x01 | In file included from /usr/include/linux/videodev2.h:65, from /usr/src/jetson_multimedia_api/include/NvBufSurface.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:8: /usr/include/linux/v4l2-controls.h:1521: note: this is the location of the previous definition 1521 | #define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x02 | In file included from /usr/src/jetson_multimedia_api/include/NvBuffer.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:9: /usr/src/jetson_multimedia_api/include/v4l2_nv_extensions.h:305: warning: "V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM" redefined 305 | #define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x02 | In file included from /usr/include/linux/videodev2.h:65, from /usr/src/jetson_multimedia_api/include/NvBufSurface.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:8: /usr/include/linux/v4l2-controls.h:1522: note: this is the location of the previous definition 1522 | #define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x04 | In file included from /usr/src/jetson_multimedia_api/include/NvBuffer.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:9: /usr/src/jetson_multimedia_api/include/v4l2_nv_extensions.h:195:8: error: redefinition of ‘struct v4l2_ctrl_h264_sps’ 195 | struct v4l2_ctrl_h264_sps { | ^~~~~~~~~~~~~~~~~~ In file included from /usr/include/linux/videodev2.h:65, from /usr/src/jetson_multimedia_api/include/NvBufSurface.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:8: /usr/include/linux/v4l2-controls.h:1306:8: note: previous definition of ‘struct v4l2_ctrl_h264_sps’ 1306 | struct v4l2_ctrl_h264_sps { | ^~~~~~~~~~~~~~~~~~ In file included from /usr/src/jetson_multimedia_api/include/NvBuffer.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:9: /usr/src/jetson_multimedia_api/include/v4l2_nv_extensions.h:224:8: error: redefinition of ‘struct v4l2_ctrl_h264_pps’ 224 | struct v4l2_ctrl_h264_pps { | ^~~~~~~~~~~~~~~~~~ In file included from /usr/include/linux/videodev2.h:65, from /usr/src/jetson_multimedia_api/include/NvBufSurface.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:8: /usr/include/linux/v4l2-controls.h:1362:8: note: previous definition of ‘struct v4l2_ctrl_h264_pps’ 1362 | struct v4l2_ctrl_h264_pps { | ^~~~~~~~~~~~~~~~~~ In file included from /usr/src/jetson_multimedia_api/include/NvBuffer.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:9: /usr/src/jetson_multimedia_api/include/v4l2_nv_extensions.h:238:8: error: redefinition of ‘struct v4l2_ctrl_h264_scaling_matrix’ 238 | struct v4l2_ctrl_h264_scaling_matrix { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/linux/videodev2.h:65, from /usr/src/jetson_multimedia_api/include/NvBufSurface.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:8: /usr/include/linux/v4l2-controls.h:1394:8: note: previous definition of ‘struct v4l2_ctrl_h264_scaling_matrix’ 1394 | struct v4l2_ctrl_h264_scaling_matrix { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/src/jetson_multimedia_api/include/NvBuffer.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:9: /usr/src/jetson_multimedia_api/include/v4l2_nv_extensions.h:243:8: error: redefinition of ‘struct v4l2_h264_weight_factors’ 243 | struct v4l2_h264_weight_factors { | ^~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/linux/videodev2.h:65, from /usr/src/jetson_multimedia_api/include/NvBufSurface.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:8: /usr/include/linux/v4l2-controls.h:1399:8: note: previous definition of ‘struct v4l2_h264_weight_factors’ 1399 | struct v4l2_h264_weight_factors { | ^~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/src/jetson_multimedia_api/include/NvBuffer.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:9: /usr/src/jetson_multimedia_api/include/v4l2_nv_extensions.h:306:8: error: redefinition of ‘struct v4l2_h264_dpb_entry’ 306 | struct v4l2_h264_dpb_entry { | ^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/linux/videodev2.h:65, from /usr/src/jetson_multimedia_api/include/NvBufSurface.h:43, from /home/myawesomecompany/dev_ws/nvidia2/NvSurfEncoder.cpp:8: /usr/include/linux/v4l2-controls.h:1542:8: note: previous definition of ‘struct v4l2_h264_dpb_entry’ 1542 | struct v4l2_h264_dpb_entry { | ^~~~~~~~~~~~~~~~~~~ make[2]: *** [CMakeFiles/test_jpeg.dir/build.make:76: CMakeFiles/test_jpeg.dir/NvSurfEncoder.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/test_jpeg.dir/all] Error 2 make: *** [Makefile:91: all] Error 2

Hi,
Here are some suggestions for the common issues:

1. Performance

Please run the below command before benchmarking deep learning use case:

$ sudo nvpmodel -m 0
$ sudo jetson_clocks

2. Installation

Installation guide of deep learning frameworks on Jetson:

3. Tutorial

Startup deep learning tutorial:

4. Report issue

If these suggestions don’t help and you want to report an issue to us, please attach the model, command/step, and the customized app (if any) with us to reproduce locally.

Thanks!

Hi @carolyuu
i am not in the process of benchmarking, i want to build the software but it fails

i tried building the sample_apllication in tegra_mulitmedia_api, which worked, but i don’t understand, why i now get the error above in my cmakelists

Hi,
It looks like it refers to multiple header files:

/usr/include/linux/videodev2.h
/usr/include/linux/v4l2-controls.h
/usr/src/jetson_multimedia_api/include/v4l2_nv_extensions.h

Please refer to only v4l2_nv_extensions.h and see if the error is not shown.

thanks for you respone @DaneLLL

yes i also think, thats the problem

however i was not able to fix the problem

CMakeLists.txt (2.2 KB)

i would be nice, if you could look into this @DaneLLL

Hi,
We would suggest refer to the Makefile in

/usr/src/jetson_multimedia_api/samples/06_jpeg_decode/Makefile

And check how to generate the same make file through CMake. By default we have the Makefile for each sample.

hi, i did exactly as you said and generate my own cmakelists.txt but i still get the same error

ok, i found out, the problem is only present in docker

i only added, the jetson_multimedia_api with following command at the end of the file

“dir, /usr/src/jetson_multimedia_api”

1 Like

but it is still not working even when i add “dir, /usr/src/jetson_multimedia_api” in the docker

Hi,
How about using Makefile? To avoid the header conflict in CMake.

i cant build a ros2 cpp node with a makefile, hence i have to use cmake

my cmakefile is definitvely correct since it works on native jetson, i just do not yet understand, why it is not working in docker on the jetson

but it is correct to just add “dir, /usr/src/jetson_multimedia_api” to
/etc/nvidia-container-runtime/host-files-for-container.d/l4t.csv
to fully use the multimedia api in the docker @DaneLLL ?

i am using the nvcr.io/nvidia/l4t-base:r36.2.0 image

I managed to solve the issue

i had to unmount the multimedia api from the docker and install manually the multimediaapi via

apt-get update && apt-get download nvidia-l4t-jetson-multimedia-api && dpkg-deb -R ./nvidia-l4t-jetson-multimedia-api_arm64.deb ./mm-api && cp -r ./mm-api/usr/src/jetson_multimedia_api /usr/src/jetson_multimedia_api && sed -i ‘s/sudo//’ ./mm-api/DEBIAN/postinst && ./mm-api/DEBIAN/postinst && rm -rf ./nvidia-l4t-jetson-multimedia-api_arm64.deb ./mm-api

from

1 Like