Cross-compile app using OpenCV4Tegra in Yocto

I’m trying to integrate a custom application into an image, using Yocto. The application relies on OpenCV4Tegra and CUDA, from the meta-toradex-tegra layer.

The application’s source code can be compiled, but linking fails with these errors:

| /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/x86_64-linux/usr/libexec/arm-SCAP-linux-gnueabi/gcc/arm-SCAP-linux-gnueabi/6.4.0/ld: warning: libjpeg.so.8, needed by /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/apalis-tk1/usr/lib/libopencv_highgui.so.2.4.13, not found (try using -rpath or -rpath-link)
| /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/x86_64-linux/usr/libexec/arm-SCAP-linux-gnueabi/gcc/arm-SCAP-linux-gnueabi/6.4.0/ld: warning: libavcodec.so.54, needed by /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/apalis-tk1/usr/lib/libopencv_highgui.so.2.4.13, not found (try using -rpath or -rpath-link)
| /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/x86_64-linux/usr/libexec/arm-SCAP-linux-gnueabi/gcc/arm-SCAP-linux-gnueabi/6.4.0/ld: warning: libavformat.so.54, needed by /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/apalis-tk1/usr/lib/libopencv_highgui.so.2.4.13, not found (try using -rpath or -rpath-link)
| /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/x86_64-linux/usr/libexec/arm-SCAP-linux-gnueabi/gcc/arm-SCAP-linux-gnueabi/6.4.0/ld: warning: libavutil.so.52, needed by /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/apalis-tk1/usr/lib/libopencv_highgui.so.2.4.13, not found (try using -rpath or -rpath-link)
| /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/x86_64-linux/usr/libexec/arm-SCAP-linux-gnueabi/gcc/arm-SCAP-linux-gnueabi/6.4.0/ld: warning: libswscale.so.2, needed by /home/vagrant/yocto/build-apalis-tk1/tmp/sysroots/apalis-tk1/usr/lib/libopencv_highgui.so.2.4.13, not found (try using -rpath or -rpath-link)

I.e. the correct versions of libjpeg, libavcodec, libavformat, libavutil and libswscale are missing. libopencv_highgui.so is installed as pre-compiled binary with the opencv4tegra recipe. These missing libraries result in a lot of missing references to these libraries slightly later on in the linking process.

The versions that are available in the sysroot are:

  • libjpeg.so.62
  • libavcodec.so.57
  • libavformat.so.57
  • libavutil.so.55
  • libswscale.so.4

Am I missing a configuration step to get the correct versions of these libraries (or is there perhaps a specific image recipe I should base my own recipe on)? Is there a way to get the correct versions of these libraries integrated into the system?

Thanks for helping.

hi @haffmans

Welcome to the Toradex Community!!!

Could you provide the software version of your module?

Did you try to cross compilation using SDK before integrating this to yocto build? If yes, does this work? If no, please try this before.

Best regards, Jaski

Hi,

We’re using the Morty branch of the meta-toradex-tegra layer (along with its dependencies), including the meta-toradex-tegra.git layer mentioned in its Readme file.

Cross compilation using the SDK works fine.

As mentioned: compilation of cpp files works fine, but the sysroot contains different versions of the dependencies than expected, causing the linker to fail. E.g. opencv4tegra relies on libjpeg.so.8, but the installed version is libjpeg.so.62.

Note that the libraries in opencv4tegra are pre-built by nvidia, so I cannot modify those to link to the available versions of the libraries.

Hi @haffmans

This is an issue in the open-embedded build, which cannot be solved at the moment. We recommend you to use NVIDIA’s JetPack resp. Linux for Tegra aka L4T.

Best regards,
Jaski