我创建了c ++本机模块,还有第三方库" sample.dylib"。运行命令 node-gyp configure 和 node-gyp build 然后 npm start 后,应用程序运行正常。但是,当我打包应用程序进行分发并运行应用程序时,我收到错误。
下面是我的binding.gyp:
{
"targets": [
{
"target_name": "mylib",
"link_settings": {
"libraries": [
"../sample.dylib"
]
},
"sources": [ "mylib_wrap.cxx"],
'cflags_cc': [
'-std=c++0x',
'-fexceptions',
'-Wall',
'-O3'
],
'xcode_settings': {
'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.7',
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'GCC_ENABLE_CPP_RTTI': 'YES',
'OTHER_CPLUSPLUSFLAGS': [
'-fexceptions',
'-Wall',
'-O3'
]
},
}
]
}
错误是:
Uncaught Error:
dlopen(/Users/<user-name>/Development/electron-quick-
start/dist/mac/electron-quick-start.app/Contents/Resources/app/build/Release/mylib.node, 1): Library not loaded: sample.dylib
Referenced from: /Users/<user-name>/Development/electron-quick-start/dist/mac/electron-quick-start.app/Contents/Resources/app/build/Release/mylib.node
Reason: image not found