Error with JPEG library

Hello!
I’m trying to build a custom version of libfreenect2, which uses nvjpeg as standard library. The project compiles but when I try to run ./Protonect I found this error:

terminate called after throwing an instance of 'std::runtime_error'
  what():  JPEG parameter struct mismatch: library thinks size is 656, caller expects 744
Aborted (core dumped)

I’ve already read some threads about a similar issue, but I don’t understand what could have caused it. Here’s the portion of my CMakeLists.txt file where I call the library, and only here:

IF(ENABLE_TEGRA_JPEG AND EXISTS "/etc/nv_tegra_release")
  FIND_LIBRARY(TEGRA_JPEG_LIBRARY nvjpeg PATHS /usr/lib/aarch64-linux-gnu/tegra NO_DEFAULT_PATH)
  IF(NOT TEGRA_JPEG_LIBRARY)
    MESSAGE(FATAL_ERROR "Did not find Tegra JPEG library")
  ENDIF(NOT TEGRA_JPEG_LIBRARY)

  INCLUDE_DIRECTORIES("${MY_DIR}/../../depends/nv_headers")

  MESSAGE(STATUS "Found Tegra hardware accelerated JPEG support")
  SET(LIBFREENECT2_WITH_TEGRA_JPEG_SUPPORT 1)

  LIST(APPEND SOURCES
    src/tegra_jpeg_rgb_packet_processor.cpp
  )
  LIST(APPEND LIBRARIES
    ${TEGRA_JPEG_LIBRARY}
  )
ENDIF()

How could it be that the project links to another library? And how can I check WHICH library is it?

Please refer to tegra_multimedia_api\samples\05_jpeg_encode

Thank you!
At the end the problem was due to the nv_headers folder, since I used it to apply a wrong header of libjpeg. I resolved the issue by changing completely the portion of code with this:

SET(HAVE_TegraJPEG disabled)
IF(ENABLE_TEGRAJPEG)
  FIND_PACKAGE(TegraJPEG)

  SET(HAVE_TegraJPEG no)
  IF(TegraJPEG_FOUND)
    SET(LIBFREENECT2_WITH_TEGRAJPEG_SUPPORT 1)
    SET(HAVE_TegraJPEG yes)

    INCLUDE_DIRECTORIES(${TegraJPEG_INCLUDE_DIRS})

    LIST(APPEND SOURCES
      src/tegra_jpeg_rgb_packet_processor.cpp
    )

    LIST(APPEND LIBRARIES
      ${CMAKE_DL_LIBS}
    )
  ENDIF()
ENDIF()

and checking that the appropriate cmake module “FindTegraJPEG” finds the correct library.
Thank you anyway for your hint, it helped me finding the right track!