c++ - 运行时无法加载由协议缓冲区静态库链接的节点 js 本机插件
问题描述
使用带有 (-fPIC enabled) 的协议缓冲区库 (3.5) 静态库构建节点 js 本机插件 (.node)。
能够构建共享库并能够与可执行文件链接。它在没有运行时协议缓冲区的情况下运行良好。
命令:
g++ -c -fPIC library.cpp //generate object file.
g++ -shared -fPIC -pthread -rdynamic -O3 -o libtest.so library.o -L . -lcrypto -lssl -lprotobuf //generate so file
g++ -Wall -o main main.cpp -L . -ltest //built executable. no issue while executing
node js 本机插件中使用的相同协议缓冲区库(3.5)静态库。编译工作正常。js 在运行时加载库失败并抛出错误。
命令:
g++ -o Release/obj.target/test.node -shared -pthread -rdynamic -m64 -Wl,-soname=test.node -Wl,--start-group Release/obj.target/main.o Release/obj.target/manager.o Release/obj.target/../../../../node_modules/node-addon-api/nothing.a -Wl,--end-group -Wl,--whole-archive ../gcc_5_4/x64/lib/release/libcrypto.a ../gcc_5_4/x64/lib/release/libssl.a ../gcc_5_4/x64/lib/release/libprotobuf.a
在抛出 'google::protobuf::FatalException' 的实例后调用终止 what():该程序需要 3.5.0 版的 Protocol Buffer 运行时库,但安装的版本是 2.6.1。请更新您的图书馆。如果您自己编译程序,请确保您的标头来自与链接时库相同版本的 Protocol Buffers。(“/local/mnt/workspace/src/main/data.pb.cc”中的版本验证失败。) [libprotobuf FATAL google/protobuf/stubs/common.cc:61] 该程序需要 3.5.0 版本的协议缓冲运行时库,但安装的版本是2.6.1。请更新您的图书馆。如果您自己编译程序,请确保您的标头来自与链接时库相同版本的 Protocol Buffers。(版本验证失败在“
你能帮我找出问题的原因吗?
解决方案
推荐阅读
- azure - Azure 负载均衡器探测和不同接口上的流量 - 可能吗?
- c# - 检查 IdExample 和 DateExample 是否已经存在并显示错误?
- python - 如何将范围作为列表元素传递给python中的列表?
- c - 如何管理链表中不同类型的数据?
- django - 从 django 获取可以为空的日期时间并将其转换为 golang
- c# - 如何实现一个通用的抽象函数?
- angular - 当一切都没有线性完成时,Angular Material Stepper Last Step 可访问
- kotlin - takeWhile 包含与谓词匹配的实际值 (takeWhileInclusive)
- java - 创建了两个 WebDriver 实例
- python - 在 python 程序中的 QtDesigner 生成的 gui 中嵌入 matplotlib 小部件