Can not find compatible jpeglib.h for NvJpegEncoder

I am trying to cross compile a simple Jpeg Encoder application, derived from the
jetson_multimedia_api/samples/05_jpeg_encode. Cross compiling from intel to arm.

The problem, there are 3 different jpeglib.h but none of them compiles with NvJpegEncoder:

the first (57.2k) in
/jetson_multimedia_api/include/libjpeg-8b (api/examples folder copied to the host from the Orin Nano)
the second (47.9k) in
/nvidia_sdk/JetPack_6.0_DP_Linux_DP_JETSON_ORIN_NANO_TARGETS/Linux_for_Tegra/rootfs/usr/include/gdcm-3.0/gdcmjpeg

for both of these jpeg_std_error() function is declared without arguments, leading to this error:

src/jpeg/NvJpegEncoder.cpp:44:31: error: too many arguments to function ‘jpeg_error_mgr* jpeg_std_error()’
   44 |     cinfo.err = jpeg_std_error(&jerr);

the third (50.3k) in nvidia_sdk/JetPack_6.0_DP_Linux_DP_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/rootfs/usr/include
has the error function defined with parameter, so the above error does not appear BUT jpeg_compress_struct is missing members that NvJpegEncoder expects.

e.g.:

src/jpeg/NvJpegEncoder.cpp:86:11: error: ‘struct jpeg_compress_struct’ has no member named ‘IsVendorbuf’
   86 |     cinfo.IsVendorbuf = TRUE;

What am I doing wrong, what am I missing?
Thanks!

Hi,

The multimedia API usually changes between JetPack versions. I suspect you are using headers from a different version to compile the sample. Have you tried compiling directly on the Jetson Orin? I tested it on an Orin NX with JetPack 5.1.2, and the sample compiled without issues:

cd /usr/src/jetson_multimedia_api/samples/05_jpeg_encode
sudo make
Compiling: jpeg_encode_csvparser.cpp
Compiling: jpeg_encode_main.cpp
make[1]: Entering directory '/usr/src/jetson_multimedia_api/samples/common/classes'
Compiling: NvElementProfiler.cpp
Compiling: NvElement.cpp
Compiling: NvApplicationProfiler.cpp
Compiling: NvVideoDecoder.cpp
Compiling: NvDrmRenderer.cpp
Compiling: NvJpegEncoder.cpp
Compiling: NvBuffer.cpp
Compiling: NvLogging.cpp
Compiling: NvEglRenderer.cpp
Compiling: NvUtils.cpp
Compiling: NvJpegDecoder.cpp
Compiling: NvVideoEncoder.cpp
Compiling: NvV4l2ElementPlane.cpp
Compiling: NvVulkanRenderer.cpp
Compiling: NvBufSurface.cpp
Compiling: NvV4l2Element.cpp
make[1]: Leaving directory '/usr/src/jetson_multimedia_api/samples/common/classes'
Linking: jpeg_encode

Thanks for the tip, yes compiling the sample locally at the orin nano worked!

Strange, since the ‘first’ included above was copied from the nano.
All files, btw, should be from same JetPack_6.0 (I never installed an older one). Also the nano was flashed from this installed JP6.

Good that I have a working starting point now, will trace my way back from there and report,
Thanks!

1 Like

Problem found/fixed:
jpeglib.h in turn includes jconfig.h and jmorecfg.h, wrong path for these were taken in the cross compile. After fixing the path, compile works.

Details of problem:
The correct jconfig.h defines #define HAVE_PROTOTYPES 1, when this is missing (by including a wrong jconfig.h) an ifdef in jpeglib.h modifies the signature of the global error function, thus breaking the compile.

Apart from this, still unclear why the JP6 contains 3 different jpeglibs, 2 of which are incompatible with the NvJpegEncoder. Can anyone expain?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.