JPEG parameter struct mismatch: library thinks size is 584, caller expects 720

I need to use:

  • nvjpeg plugin from GStreamer (requires NVIDIA’s libjpeg)

  • OpenCV (requires standard libjpeg-turbo)

When I run both in the same process, I get this error:
JPEG parameter struct mismatch: library thinks size is 584, caller expects 720

How can I make GStreamer’s nvjpeg plugin use NVIDIA’s libjpeg while OpenCV uses the system libjpeg in the same process without conflicts?