"Missing Shared Libraries Error When Running OpenCV Binary on Target System After Cross-Compilation"

I am performing cross-compilation for my project using the TDX Linux SDK for my specific hardware. I have also installed OpenCV on the target system. During the compilation process, everything works properly. However, when I try to run the binary file on the target system, I encounter an error stating that some libraries are missing:
./basic_opencv: error while loading shared libraries: libopencv_ts.so.406: cannot open shared object file: No such file or directory
Note : opencv related libraries are fetched in sdk already)

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


The error you’re encountering indicates that the specific OpenCV library libopencv_ts.so.406 is not found on your target system, even though it might be present in your SDK. Here are the steps you can take to resolve this issue:

  1. Verify Installation on Target: Ensure that the OpenCV libraries, including libopencv_ts.so.406, are installed on the target system. The presence of these libraries in the SDK does not automatically mean they are available on the target.

  2. Check Library Paths: Make sure that the library paths on the target system are correctly set. The dynamic linker needs to find the required libraries when executing the binary. You can check and set the library paths using environment variables like LD_LIBRARY_PATH.

  3. Use ldd for Troubleshooting: On the target system, use the command ldd ./basic_opencv to list the shared libraries linked to your binary and identify any that are missing.

  4. Ensure Version Compatibility: Verify that the version of OpenCV installed on the target system matches the version used during cross-compilation. Mismatches can lead to such errors.

  5. Reinstall or Update OpenCV: If the required library is not found, consider reinstalling OpenCV on the target system or updating it to include the missing library.

By following these steps, you should be able to resolve the missing library issue and successfully run your OpenCV binary on the target system.

Please, also check if these links can help you solve your problem:

Cross Compilation for opencv C++.

Hi @Seyad

Sorry for the delay.

As suggested by @ToradexAI, have you checked if the dependencies libraries are present on the target device?

Can you explain how you installed it on your target system?