Plugin depending on another library - Couldn't open <library>, error: undefined symbol

I’ve been banging my head against this bug and making incremental progress. It’s similar to a recent forum post [Unity Linux Plugin depending on third party library DllNotFoundException - Unity Engine - Unity Discussions] but the fix Tak suggested isn’t working for me. It’s about as likely that that problem is coming from Unity as any other part of my build process, but I’m hoping someone can help out here.

The error:

Couldn’t open Assets/Plugins/libopencv_unity.so, error: Assets/Plugins/libopencv_unity.so: undefined symbol: _ZN2cv12VideoCaptureD1Ev
OpenCVFaceDetection:Start() (at Assets/OpenCVFaceDetection.cs:43)
OpenCVFaceDetection:Start() (at Assets/OpenCVFaceDetection.cs:23)

Just as in the thread linked above, the library I’m referencing has the right symbol, and it’s in the Assets/Plugins/ directory:

mark@isidore-seville:~/miniprojects/unity/wrapping/Assets/Plugins$ nm libopencv_videoio.so | grep _ZN2cv12VideoCaptureD1Ev
0000000000007ac0 T _ZN2cv12VideoCaptureD1Ev

However, I’ve made the change to the library I built [which references opencv_videoio] to set the RPATH as $ORIGIN:

mark@isidore-seville:~/miniprojects/unity/wrapping/Assets/Plugins$ objdump -x libopencv_unity.so | grep RPATH
RPATH $ORIGIN

and yet I still get the same error as above. Any tips? I’m fairly new to Unity, especially plugins - maybe I’ve got the plugins in the wrong place?

Mark

Found the solution! My ldd output didn’t refer to any sort of other library, and I had expected the library creation step to error out if I needed to link against the OpenCV libraries [just as it would if I were linking some of my own C++ code]. I was using CMake and it turns out I needed to add the “target_link_libraries” option to link against OpenCV.

1 Like

What do you think of this error? Any one on earth is fine, so please tell me how to solve this error quickly!