Ubuntu 20.04下编译OpenCV-Python C模块后导入出现未定义符号错误的问题咨询
Ubuntu 20.04下编译OpenCV-Python C模块后导入出现未定义符号错误的问题咨询
我正在尝试使用一个用于图像处理的OpenCV-Python C模块仓库,在Ubuntu 18.04电脑上编译完全正常,但在Ubuntu 20.04电脑上使用Python3.8导入库时遇到了错误。
导入时的终端输出如下:
python3.8 Python 3.8.10 (default, May 26 2023, 14:05:08) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import helloWorld /home/xavier/.local/lib/python3.8/site-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.15) or chardet (3.0.4) doesn't match a supported version! warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported " Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: /usr/local/lib/python3.8/dist-packages/helloWorld-1.0-py3.8-linux-x86_64.egg/helloWorld.abi3.so: undefined symbol: _ZN5pbcvt16fromMatToNDArrayERKN2cv3MatE
我在第二台电脑上用的是Python3.8,为什么编译在这台电脑上无法正常工作呢?
我查看了生成的库文件helloWorld.abi3.so,找不到对应的符号,执行以下命令后的输出如下:
readelf -s /usr/local/lib/python3.8/dist-packages/helloWorld-1.0-py3.8-linux-x86_64.egg/helloWorld.abi3.so | grep fromMatToNDA -A 2 -B 2 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __cxa_atexit@GLIBC_2.2.5 (2) 7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail@GLIBC_2.4 (3) 8: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _ZN5pbcvt16fromMatToNDArr 9: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND PyArg_ParseTuple 10: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _ZN5pbcvt16fromNDArrayToM -- 72: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __cxa_atexit@@GLIBC_2.2.5 73: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail@@GLIBC_2 74: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _ZN5pbcvt16fromMatToNDArr 75: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND PyArg_ParseTuple 76: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _ZN5pbcvt16fromNDArrayToM
备注:内容来源于stack exchange,提问作者Xavier12358




