我正在编写代码以从电子加载 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 中,我也尝试过重新安装节点模块和电子重建。它们都不适合我。除了本机 .node 模块外,dylib 已成功复制。不知道为什么会出现此链接错误