What Do I Do If "libprotoc.so.19: undefined symbol" Is Reported When Building a Caffe Operator Project?
Symptom
The following error is reported when building a Caffe custom operator project:
2020-08-21 04:46:16] [INFO] End of pre proc for /xxx/atc/sample/op/caffe/caffe.proto.[2020-08-21 04:46:16] [INFO] Compile caffe proto.protoc: symbol lookup error: /xxx/lib/libprotoc.so.19: undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameB5cxx11Ev[2020-08-21 04:46:16] [ERROR] Protoc run failed, maybe need to compare the merged proto with origin or check your custom proto.
Cause Analysis
- Check the dynamic library linked to the libprotoc.so.19 file.
ldd /xxx/lib/libprotoc.so.19
The command output is similar to the following:
- Check the LD_LIBRARY_PATH environment variable configured in the current environment.
echo $LD_LIBRARY_PATH
The command output is similar to the following:
xxx:/usr/local/Ascend/add-ons:xxx
The LD_LIBRARY_PATH environment variable contains /usr/local/Ascend/add-ons but the /xxx/lib/libprotoc.so.19 file is linked to the protobuf library file in the Driver runfile instead of the user-defined protobuf library, resulting in the mismatch between the library file version and the protoc command.
Solution
Add the path of the user-defined protobuf library file to the LD_LIBRARY_PATH variable in the build.sh script, for example:
export LD_LIBRARY_PATH=/home/HwHiAiUser/protobuf_install/lib