【问题标题】:Issue Building Electron App with Opencv4nodejs on Windows 10在 Windows 10 上使用 Opencv4nodejs 构建电子应用程序的问题
【发布时间】:2020-10-04 00:19:33
【问题描述】:

我已经构建了一个使用 tensorflow 和 opencv4nodejs 的电子应用程序。

当我使用npm start 时,该应用程序运行良好。但是,当我尝试构建我的应用程序时,它会出现以下错误:

这里的问题是我没有从源代码构建 opencv4nodejs。相反,我手动安装了 opencv,然后禁用了自动构建来为我的应用安装它。

从错误中,我看到它正在寻找 opencv-build 下的 lib 目录,但它根本不存在。

由于我已经为 Windows 10 构建了所有模块,有没有办法不重新构建任何东西?

我确信这很简单,但为此碰壁了。

这是我的 package.json `

{
  "name": "myApp",
  "version": "0.0.1",
  "description": "My Electron App",
  "main": "main.js",
  "license": "abc",
  "private": true,
  "scripts": {
    "postinstall": "install-app-deps",
    "start": "electron .",
    "build": "electron-packager . nGage --platform win32 --arch x64 --out dist/ --icon image/nGage-Icon.ico --overwrite",
    "setup": "electron-installer-windows --src dist/nGage-win32-x64/ --dest dist/installers/ --config config.json --overwrite",
    "dist": "build"
  },
  "build": {
    "appId": "com.electron.app",
    "publish": [
      {
        "provider": "generic",
        "url": "abc"
      }
    ],
    "win": {
      "target": [
        {
          "target": "nsis",
          "arch": [
            "x64"
          ]
        }
      ],
      "certificateFile": "cert/abc",
      "certificatePassword": "xyz"
    },
    "asar": false,
    "nsis": {
      "oneClick": true,
      "perMachine": false,
      "artifactName": "${productName}-Setup-${version}-x64.${ext}"
    }
  },
  "author": {
    "name": "ABC",
    "email": "xyz@abc.com",
    "url": "www.abc.com"
  },
  "devDependencies": {
    "electron": "^9.0.3",
    "electron-builder": "^19.53.6",
    "electron-installer-windows": "^0.2.0",
    "electron-packager": "^8.5.2",
    "electron-winstaller": "^2.5.2",
    "grunt-electron-installer": "^2.1.0"
  },
  "dependencies": {
    "@tensorflow/tfjs": "^2.0.0",
    "@tensorflow/tfjs-node": "^2.0.0",
    "auto-launch": "^5.0.1",
    "cron": "^1.2.1",
    "electron-config": "^0.2.1",
    "electron-positioner": "^3.0.0",
    "electron-squirrel-startup": "^1.0.0",
    "electron-updater": "^2.19.0",
    "electron-window": "^0.8.1",
    "graceful-fs": "^4.1.11",
    "homedir": "^0.6.0",
    "https": "^1.0.0",
    "opencv4nodejs": "^5.6.0",
    "request": "^2.88.2",
    "url": "^0.11.0",
    "username": "^3.0.0",
    "util": "^0.12.3",
    "windows-build-tools": "^5.2.2"
  }
}

` 任何见解都会很有帮助!

谢谢, 阿伦

【问题讨论】:

    标签: node.js electron electron-builder electron-packager opencv4nodejs


    【解决方案1】:

    所以我意识到在做npm run build之前需要设置以下环境变量

    因为我在构建opencv4nodejs 时使用过它们。这是我从the opencv4nodejs site. 中获取的内容

    `

    Installing OpenCV Manually
    Setting up OpenCV on your own will require you to set an environment variable to prevent the auto build script to run:
    
    # linux and osx:
    export OPENCV4NODEJS_DISABLE_AUTOBUILD=1
    # on windows:
    set OPENCV4NODEJS_DISABLE_AUTOBUILD=1
    Windows
    You can install any of the OpenCV 3 or OpenCV 4 releases manually or via the Chocolatey package manager:
    
    # to install OpenCV 4.1.0
    choco install OpenCV -y -version 4.1.0
    Note, this will come without contrib modules. To install OpenCV under windows with contrib modules you have to build the library from source or you can use the auto build script.
    
    Before installing opencv4nodejs with an own installation of OpenCV you need to expose the following environment variables:
    
    OPENCV_INCLUDE_DIR pointing to the directory with the subfolder opencv2 containing the header files
    OPENCV_LIB_DIR pointing to the lib directory containing the OpenCV .lib files
    Also you will need to add the OpenCV binaries to your system path:
    
    add an environment variable OPENCV_BIN_DIR pointing to the binary directory containing the OpenCV .dll files
    append ;%OPENCV_BIN_DIR%; to your system path variable
    

    `

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-17
      • 1970-01-01
      • 1970-01-01
      • 2021-06-21
      • 2016-02-21
      • 2021-08-05
      • 2020-12-12
      • 2021-02-19
      相关资源
      最近更新 更多