Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 运行时无法加载由协议缓冲区静态库链接的节点js本机加载项_C++_Node.js_G++_Ubuntu 16.04 - Fatal编程技术网

C++ 运行时无法加载由协议缓冲区静态库链接的节点js本机加载项

C++ 运行时无法加载由协议缓冲区静态库链接的节点js本机加载项,c++,node.js,g++,ubuntu-16.04,C++,Node.js,G++,Ubuntu 16.04,使用协议缓冲库(3.5)静态库和(-fPIC已启用)构建节点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 f

使用协议缓冲库(3.5)静态库和(-fPIC已启用)构建节点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
  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
与node js本机插件中使用的协议缓冲库(3.5)静态库相同。编辑工作做得很好。js在运行时加载库失败,并引发错误

命令:

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
  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”实例后调用terminate what():此程序需要3.5.0版的协议缓冲区运行库,但安装的版本是2.6.1。请更新您的库。如果您自己编译了该程序,请确保您的头来自与链接时间库相同版本的协议缓冲区。(版本验证在“/local/mnt/workspace/src/main/data.pb.cc”中失败。) [libprotobuf FATAL google/protobuf/stubs/common.cc:61]此程序需要3.5.0版的协议缓冲区运行库,但安装的版本是2.6.1。请更新您的库。如果您自己编译了该程序,请确保您的头来自与链接时间库相同版本的协议缓冲区。(版本验证在“/local/mnt/workspace/src/main/data.pb.cc”中失败。

您能帮我找到问题的原因吗?

发现Electron加载了“libprotobuf lite.so.9”共享库。即使我们将“libprotobuf.a”3.5库静态链接到本机加载项。我不知道,我们如何告诉Electron使用最新的共享库而不是环境路径。