使用本机模块封装电子后未发现图像错误

时间:2018-03-29 11:37:36

标签: node.js electron electron-builder

我创建了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

0 个答案:

没有答案