Conflict between libjpeg.so.8 and libnvjpeg.so when using opencv and encodeFromFd interface in the same program

When I used encodeFromFd interface to do jpeg encode, the program crashed and the printing was as follows:JPEG parameter struct mismatch: library thinks size is 584, caller expects 728.After troubleshooting,I found that libjpeg.so.8 library that opencv depends on and libnvjpeg.so library that encodeFromFd interface depends on conflict due to the existence of functions with the same name.I tried to use compile options “-Wl,rpath=dynamic library path” to specify libnvjpeg.so library path when using encodeFromFd interface, but it didn’t work.My program needs to use opencv and encodeFromFd interface.Do you have any good solutions?

Hi,
This conflict is known and we don’t support this use-case. Please check explanation in
OpenCV with libnvjpeg - #5 by DaneLLL

We would suggest use libjpeg.so in OpenCV.