12/19/2020

Debug symbol lookup error: undefined symbol: _ZN2cv8imencodeERKNS_6StringERKNS_11_InputArrayERSt6vectorIhSaIhEERKS6_IiSaIiEE

symbol lookup error: /home/liangzou/.cache/bazel/_bazel_liangzou/766790ddbe8cf965fa78098dbd133c63/execroot/__main__/bazel-out/k8-fastbuild/bin/external/deepmap_base/common/image/../../../../_solib_k8/libexternal_Sdeepmap_Ubase_Scommon_Simage_Slibio_Uutils.so: undefined symbol: _ZN2cv8imencodeERKNS_6StringERKNS_11_InputArrayERSt6vectorIhSaIhEERKS6_IiSaIiEE

The function definition is in this library: libopencv_imgcodecs.a

objdump -t libopencv_imgcodecs.a | grep _ZN2cv8imencodeERKNS_6StringERKNS_11_InputArrayERSt6vectorIhSaIhEERKS6_IiSaIiEE

0000000000000000 g     F .text._ZN2cv8imencodeERKNS_6StringERKNS_11_InputArrayERSt6vectorIhSaIhEERKS6_IiSaIiEE  0000000000000888 .hidden _ZN2cv8imencodeERKNS_6StringERKNS_11_InputArrayERSt6vectorIhSaIhEERKS6_IiSaIiEE

So the function is hidden.

In the opencv library repo file: opencv2/core/cvdef.h, it has:
#ifdef CVAPI_EXPORTS
# if (defined _WIN32 || defined WINCE || defined __CYGWIN__)
#   define CV_EXPORTS __declspec(dllexport)
# elif defined __GNUC__ && __GNUC__ >= 4
#   define CV_EXPORTS __attribute__ ((visibility ("default")))
# endif
#endif

#ifndef CV_EXPORTS
# define CV_EXPORTS
#endif

For some reason, the CV_EXPORTS didn't take effect. Need to change:
#ifndef CV_EXPORTS
# define CV_EXPORTS __attribute__ ((visibility ("default")))
#endif

No comments: