Tegra_multimedia_api\samples\05_jpeg_encode run time error

Hi,

I built tegra_multimedia_api/samples/05_jpeg_encode
on Tx2 with xEC2 board. but I got the following error message during run-time. "JPEG parameter struct mismatch: library thinks size is 728, caller expects 704"

It is a lib conflict problem between libjpeg and libnvjpeg based on the discussion in this forum. Maybe I missed something, I did not find a clear answer on how to fix this issue. Therefore I post it again.

BTW, i did not build and install opencv yet. Here is my L4T version
$cat /etc/nv_tegra_release
R32 (release), REVISION: 3.1, GCID: 18186506, BOARD: t186ref, EABI: aarch64, DATE: Tue Dec 10 07:03:07 UTC 2019

Here is my compile and link command.
g++ -I"/usr/include/aarch64-linux-gnu" -I"…/…/include" -I"…/…/include/libjpeg-8b" -c jpeg_encode_csvparser.cpp

g++ -I"/usr/include/aarch64-linux-gnu" -I"…/…/include" -I"…/…/…/include" -I"…/…/…/include/libjpeg-8b" -c NvJpegEncoder.cpp

g++ -o jpeg_encode jpeg_encode_csvparser.o jpeg_encode_main.o …/common/classes/NvElementProfiler.o …/common/classes/NvElement.o …/common/classes/NvApplicationProfiler.o …/common/classes/NvVideoDecoder.o …/common/classes/NvJpegEncoder.o …/common/classes/NvVideoConverter.o …/common/classes/NvBuffer.o …/common/classes/NvLogging.o …/common/classes/NvEglRenderer.o …/common/classes/NvUtils.o …/common/classes/NvJpegDecoder.o …/common/classes/NvVideoEncoder.o …/common/classes/NvV4l2ElementPlane.o …/common/classes/NvV4l2Element.o -I"/usr/include/aarch64-linux-gnu" -I"…/…/include" -I"…/…/include/libjpeg-8b" -L"/usr/lib/aarch64-linux-gnu" -L"/usr/lib/aarch64-linux-gnu/tegra" -lpthread -lv4l2 -lEGL -lGLESv2 -lX11 -lnvbuf_utils -lnvjpeg

The following is the global search results of the related lib and headers in my machine:

A.
nvidia@ubuntu:/$ sudo find / -name libjpeg.*

/usr/lib/aarch64-linux-gnu/libjpeg.so.9

/usr/lib/aarch64-linux-gnu/libjpeg.so.9.2.0

/usr/lib/aarch64-linux-gnu/vlc/plugins/codec/libjpeg_plugin.so

/usr/lib/aarch64-linux-gnu/libjpeg.so.8

/usr/lib/aarch64-linux-gnu/libjpeg.so.8.1.2

B.

nvidia@ubuntu:/$sudo find / -name libnvjpeg.*

/usr/lib/aarch64-linux-gnu/tegra/libnvjpeg.so

C.

nvidia@ubuntu:/$ sudo find / -name jpeglib.h

/home/nvidia/pkg/tegra/tegra_multimedia_api/include/libjpeg-8b/jpeglib.h

/home/nvidia/susa_wami/src/server/libAppJpeg/libjpeg-8b/jpeglib.h

Thanks for your help!