Mac 中我在 Electron 中使用本机 C++ 插件的问题
Problem with my Native C++ Addon in Electron in Mac
我正在编写代码以从 electron 加载 c++ 动态库。在 Mac 中尝试时出现以下错误:
dyld:找不到符号:__ZN15FcDrive2Library13InitDrive2LibEv
引用自:/Users/nikhell/Documents/Codelathe/Workspace/cl-fc-client/electron-drive-client/build/Release/electronToCppBridge.node
预计在:平面命名空间
我的 binding.gyp 文件如下所示:
{
"targets":[
{
"target_name": "electronToCppBridge",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
'include_dirs': [
"<!@(node -p \"require('node-addon-api').include\")"
],
'dependencies': [
"<!(node -p \"require('node-addon-api').gyp\")"
],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
"copies":[
{
'destination': './node_modules/electron/dist',
'files':[
'../../cl-fc-client/release/support/common/clientca.pem',
'../../cl-fc-client/release/support/common/clientcert.pem',
'../../cl-fc-client/clouddrive2/config.xml',
'../../cl-fc-client/release/support/prebuilt/translationsdc.zip'
]
},
{
'destination': './src',
'files':['../cloudDrive2Lib/LibraryEntry/cloudDrive2Library.h']
}
],
"conditions":[
["OS=='win'",
{
"copies":[
{
'destination': './build/Release',
'files':[
'../../cl-fc-client-thirdparty/bugtrap/BugTrapU-x64.dll',
'../build/bin/msvc/Release64/cloudDrive2Lib.dll',
'../../cl-fc-client-thirdparty/openssl/1.0.2j/lib/x86_64-win32/ssleay32MD.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoZip64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoXML64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoUtil64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoNetSSL64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoNet64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoJSON64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoFoundation64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoCrypto64.dll',
'../../cl-fc-client-thirdparty/openssl/1.0.2j/lib/x86_64-win32/libeay32MD.dll'
]
},
{
'destination': './libs',
'files':['../build/bin/msvc/Release64/cloudDrive2Lib.lib']
},
],
"sources": [
"src/electronToCppBridge.cc",
],
}
],
["OS=='mac'",
{
"copies":[
{
'destination': './build/Release',
'files':[
'../build/bin/darwin/release/libfileclouddrive2lib.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoCrypto.45.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoFoundation.45.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoJSON.45.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoNet.45.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoNetSSL.45.dylib'
]
},
{
'destination': './libs',
'files':[
'../build/bin/darwin/release/libfileclouddrive2lib.dylib'
]
},
],
"sources": [
"src/electronToCppBridge.cc",
"libs/libfileclouddrive2lib.dylib",
],
}
]
],
}
]
}
它正在 windows 工作。在 Mac 中,我尝试重新安装节点模块和电子重建。 None 其中对我有用。除了本机 .node 模块之外,dylib 已成功复制。不知道为什么会出现这个 link 错误
没关系。我意识到 link_dependencies 标签需要添加到 binding.gyp 中。此外,dylib 需要复制到项目的根目录。
我正在编写代码以从 electron 加载 c++ 动态库。在 Mac 中尝试时出现以下错误:
dyld:找不到符号:__ZN15FcDrive2Library13InitDrive2LibEv 引用自:/Users/nikhell/Documents/Codelathe/Workspace/cl-fc-client/electron-drive-client/build/Release/electronToCppBridge.node 预计在:平面命名空间
我的 binding.gyp 文件如下所示:
{
"targets":[
{
"target_name": "electronToCppBridge",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
'include_dirs': [
"<!@(node -p \"require('node-addon-api').include\")"
],
'dependencies': [
"<!(node -p \"require('node-addon-api').gyp\")"
],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
"copies":[
{
'destination': './node_modules/electron/dist',
'files':[
'../../cl-fc-client/release/support/common/clientca.pem',
'../../cl-fc-client/release/support/common/clientcert.pem',
'../../cl-fc-client/clouddrive2/config.xml',
'../../cl-fc-client/release/support/prebuilt/translationsdc.zip'
]
},
{
'destination': './src',
'files':['../cloudDrive2Lib/LibraryEntry/cloudDrive2Library.h']
}
],
"conditions":[
["OS=='win'",
{
"copies":[
{
'destination': './build/Release',
'files':[
'../../cl-fc-client-thirdparty/bugtrap/BugTrapU-x64.dll',
'../build/bin/msvc/Release64/cloudDrive2Lib.dll',
'../../cl-fc-client-thirdparty/openssl/1.0.2j/lib/x86_64-win32/ssleay32MD.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoZip64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoXML64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoUtil64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoNetSSL64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoNet64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoJSON64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoFoundation64.dll',
'../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoCrypto64.dll',
'../../cl-fc-client-thirdparty/openssl/1.0.2j/lib/x86_64-win32/libeay32MD.dll'
]
},
{
'destination': './libs',
'files':['../build/bin/msvc/Release64/cloudDrive2Lib.lib']
},
],
"sources": [
"src/electronToCppBridge.cc",
],
}
],
["OS=='mac'",
{
"copies":[
{
'destination': './build/Release',
'files':[
'../build/bin/darwin/release/libfileclouddrive2lib.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoCrypto.45.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoFoundation.45.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoJSON.45.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoNet.45.dylib',
'../../cl-fc-client-thirdparty/poco/1.7.5/lib/Darwin/x86_64/libPocoNetSSL.45.dylib'
]
},
{
'destination': './libs',
'files':[
'../build/bin/darwin/release/libfileclouddrive2lib.dylib'
]
},
],
"sources": [
"src/electronToCppBridge.cc",
"libs/libfileclouddrive2lib.dylib",
],
}
]
],
}
]
}
它正在 windows 工作。在 Mac 中,我尝试重新安装节点模块和电子重建。 None 其中对我有用。除了本机 .node 模块之外,dylib 已成功复制。不知道为什么会出现这个 link 错误
没关系。我意识到 link_dependencies 标签需要添加到 binding.gyp 中。此外,dylib 需要复制到项目的根目录。