I'm augmenting the Java wrapper for OpenCV with some of my own code. In a nutshell here is my build process:
- On Ubuntu 16.04 I'm building OpenCV (3.4.0) Java wrapper statically linked so that all of the rest of the OpenCV libraries is in the JNI library.
- I have my own JNI library built as a separate shared library with code against the C++ implementation of OpenCV
- I explicitly
System.load()
both shared libraries into my java code.
I have much of it working except one method that seems to trigger the following error
java: symbol lookup error: [path to my library].so: undefined symbol: _ZN2cv6String8allocateEm
This is the cv::String::allocate
method from stl.cpp
. Using nm
on the OpenCV library I can see the symbol is defined as local (indicated by the lower case 't'):
0000000000442990 t _ZN2cv6String8allocateEm
When I run make
with VERBOSE=1
I can see that -fvisibility=hidden
is being passed to the compiler for stl.cpp
.
If this is intentional can someone please let me know what I'm supposed to do. Obviously this will work if I build my code directly into the OpenCV shared library I'm building but I'd prefer not to do that. I'm using the public C++ interface for OpenCV which results in that call being made even though I'm not doing it explicitly. I'm calling imshow
from my C++ wrappers.
Any suggestions?
Thanks