vosk-api icon indicating copy to clipboard operation
vosk-api copied to clipboard

Dynamic Linking Error Win32 error 127

Open bertyhell opened this issue 2 years ago • 11 comments

I'm trying to get vosk to work inside nodeJS on Windows:

  • Window 10 21H1 (OS Build 19043.1288)
  • NodeJS v16.10.0
  • npm 7.24.2
  • vosk 0.3.32

But i get this error:

> node index.js

C:\Users\...\repos\subtitle-syncer\node_modules\ffi-napi\lib\dynamic_library.js:75
    throw new Error('Dynamic Linking Error: ' + err);
    ^

Error: Dynamic Linking Error: Win32 error 127
    at new DynamicLibrary (C:\Users\...\repos\subtitle-syncer\node_modules\ffi-napi\lib\dynamic_library.js:75:11)
    at Object.Library (C:\Users\...\repos\subtitle-syncer\node_modules\ffi-napi\lib\library.js:47:10)
    at Object.<anonymous> (C:\...\repos\subtitle-syncer\node_modules\vosk\index.js:84:21)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\...\repos\subtitle-syncer\index.js:67:30)

Process finished with exit code 1

I've already tried or read through the threads on:

  • https://github.com/alphacep/vosk-api/issues/538
  • https://github.com/alphacep/vosk-api/issues/457 This doesn't seem to work/change the error. eg: adding C:\Users...\repos\subtitle-syncer\node_modules\vosk\lib to my PATH env variable.

I installed vosk using the python command:

>pip3 install vosk
Collecting vosk
  Downloading vosk-0.3.32-py3-none-win_amd64.whl (11.9 MB)
     |████████████████████████████████| 11.9 MB 3.3 MB/s
Collecting cffi>=1.0
  Downloading cffi-1.15.0-cp310-cp310-win_amd64.whl (180 kB)
     |████████████████████████████████| 180 kB 6.4 MB/s
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     |████████████████████████████████| 118 kB 6.4 MB/s
Installing collected packages: pycparser, cffi, vosk
Successfully installed cffi-1.15.0 pycparser-2.21 vosk-0.3.32

And then also inside node:

npm i vosk

My code is public on this repo: https://github.com/bertyhell/subtitle-syncer

clone https://github.com/bertyhell/subtitle-syncer.git subtitle-syncer
cd subtitle-syncer
npm i
npm run start

bertyhell avatar Nov 08 '21 21:11 bertyhell

Most likely you have 32-bit node. We only support 64-bit.

nshmyrev avatar Nov 08 '21 21:11 nshmyrev

I installed vosk using the python command:

You don't need python for node module

nshmyrev avatar Nov 08 '21 21:11 nshmyrev

ok, i reinstalled NodeJS x64 and now it works:

file: node-v16.13.0-x64.msi

thx for the help.

bertyhell avatar Nov 11 '21 09:11 bertyhell

oeps, this worked because i tried it on another pc. On my laptop it still fails.

i tried reinstalling nodejs x64 on my laptop but it didn't help.

nodejs info:

> process
process {
  version: 'v16.13.0',
  versions: {
    node: '16.13.0',
    v8: '9.4.146.19-node.13',
    uv: '1.42.0',
    zlib: '1.2.11',
    brotli: '1.0.9',
    ares: '1.17.2',
    modules: '93',
    nghttp2: '1.45.1',
    napi: '8',
    llhttp: '6.0.4',
    openssl: '1.1.1l+quic',
    cldr: '39.0',
    icu: '69.1',
    tz: '2021a',
    unicode: '13.0',
    ngtcp2: '0.1.0-DEV',
    nghttp3: '0.1.0-DEV'
  },
  arch: 'x64',
  platform: 'win32',
  release: {
    name: 'node',
    lts: 'Gallium',
    sourceUrl: 'https://nodejs.org/download/release/v16.13.0/node-v16.13.0.tar.gz',
    headersUrl: 'https://nodejs.org/download/release/v16.13.0/node-v16.13.0-headers.tar.gz',
    libUrl: 'https://nodejs.org/download/release/v16.13.0/win-x64/node.lib'
  },
  _rawDebug: [Function: _rawDebug],
      PATHEXT: '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW',
    PROCESSOR_ARCHITECTURE: 'AMD64',
    PROCESSOR_IDENTIFIER: 'Intel64 Family 6 Model 158 Stepping 10, GenuineIntel',
    PROCESSOR_LEVEL: '6',
    PROCESSOR_REVISION: '9e0a',
    ProgramData: 'C:\\ProgramData',
    ProgramFiles: 'C:\\Program Files',
    'ProgramFiles(x86)': 'C:\\Program Files (x86)',
    ProgramW6432: 'C:\\Program Files',
    PROMPT: '$P$G',
    PUBLIC: 'C:\\Users\\Public',
    SESSIONNAME: 'Console',
    SystemDrive: 'C:',
    SystemRoot: 'C:\\WINDOWS',
    TEMP: 'C:\\Users\\bert\\AppData\\Local\\Temp',
    TMP: 'C:\\Users\\bert\\AppData\\Local\\Temp',
    USERDOMAIN: 'DESKTOP-K9VNH6V',
    USERDOMAIN_ROAMINGPROFILE: 'DESKTOP-K9VNH6V',
    USERNAME: 'bert',
    USERPROFILE: 'C:\\Users\\bert',
    VS140COMNTOOLS: 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools',
    windir: 'C:\\WINDOWS',
    ZES_ENABLE_SYSMAN: '1'
  },
  title: 'C:\\Windows\\System32\\cmd.exe - node',
  argv: [ 'C:\\Program Files\\nodejs\\node.exe' ],
  execArgv: [],
  pid: 6668,
  ppid: 12488,
  execPath: 'C:\\Program Files\\nodejs\\node.exe',
  debugPort: 9229,
  hrtime: [Function: hrtime] { bigint: [Function: hrtimeBigInt] },
  argv0: 'node',
  _preload_modules: [],
  setSourceMapsEnabled: [Function: setSourceMapsEnabled],
  [Symbol(kCapture)]: false

libvosk.dll info from dumpbin:

...\node_modules\vosk\lib\win-x86_64>dumpbin /ALL libvosk.dll
Microsoft (R) COFF/PE Dumper Version 14.29.30136.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file libvosk.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
            8664 machine (x64)
               B number of sections
        617DBBA6 time date stamp Sat Oct 30 23:39:50 2021
               0 file pointer to symbol table
               0 number of symbols
              F0 size of optional header
            222E characteristics
                   Executable
                   Line numbers stripped
                   Symbols stripped
                   Application can handle large (>2GB) addresses
                   Debug information stripped
                   DLL

OPTIONAL HEADER VALUES
             20B magic # (PE32+)
            2.31 linker version
         151F400 size of code
         17F4C00 size of initialized data
            AA00 size of uninitialized data
            1330 entry point (000000006F241330)
            1000 base of code
        6F240000 image base (000000006F240000 to 0000000070A45FFF)
            1000 section alignment
             200 file alignment
            4.00 operating system version
            0.00 image version
            5.02 subsystem version
               0 Win32 version
         1806000 size of image
             400 size of headers
         17FCCF8 checksum
               3 subsystem (Windows CUI)
             160 DLL characteristics
                   High Entropy Virtual Addresses
                   Dynamic base
                   NX compatible
          200000 size of stack reserve
            1000 size of stack commit
          100000 size of heap reserve
            1000 size of heap commit
               0 loader flags
              10 number of directories
         1687000 [  171B63] RVA [size] of Export Directory
         17F9000 [    37BC] RVA [size] of Import Directory
               0 [       0] RVA [size] of Resource Directory
         15D5000 [   2D288] RVA [size] of Exception Directory
               0 [       0] RVA [size] of Certificates Directory
         17FF000 [    6884] RVA [size] of Base Relocation Directory
               0 [       0] RVA [size] of Debug Directory
               0 [       0] RVA [size] of Architecture Directory
               0 [       0] RVA [size] of Global Pointer Directory
         158C000 [      28] RVA [size] of Thread Storage Directory
               0 [       0] RVA [size] of Load Configuration Directory
               0 [       0] RVA [size] of Bound Import Directory
         17F997C [     8F0] RVA [size] of Import Address Table Directory
               0 [       0] RVA [size] of Delay Import Directory
               0 [       0] RVA [size] of COM Descriptor Directory
               0 [       0] RVA [size] of Reserved Directory


SECTION HEADER #1
   .text name
 151F328 virtual size
    1000 virtual address (000000006F241000 to 0000000070760327)
 151F400 size of raw data
     400 file pointer to raw data (00000400 to 0151F7FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60A00060 flags
         Code
         Initialized Data
         RESERVED - UNKNOWN
         RESERVED - UNKNOWN
         Execute Read

The error when i execute the program in node:

> ts-node subtitle-syncer.ts ./example2/Alone-S02E05-Storm-Rising.mkv ./example2/Alone-S02E05-Storm-Rising.srt

C:\Users\...\subtitle-syncer\node_modules\ffi-napi\lib\dynamic_library.js:75
    throw new Error('Dynamic Linking Error: ' + err);
          ^
Error: Dynamic Linking Error: Win32 error 127
    at new DynamicLibrary (C:\Users\...\node_modules\ffi-napi\lib\dynamic_library.js:75:11)
    at Object.Library (C:\Users\...\node_modules\ffi-napi\lib\library.js:47:10)
    at Object.<anonymous> (C:\Users\...\node_modules\vosk\index.js:84:21)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .js] (C:\Users\...\node_modules\ts-node\src\index.ts:1361:43)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)

If i debug at the failure point: image

I double checked that this file does exist:

C:\Users\...\subtitle-syncer\node_modules\vosk\lib\win-x86_64\libvosk.dll

bertyhell avatar Nov 19 '21 07:11 bertyhell

Same Error over here

h110m avatar Dec 05 '21 22:12 h110m

similar problem

k0t0fey avatar Jan 18 '22 14:01 k0t0fey

same problem here

Ultimate-Storm avatar Feb 21 '22 03:02 Ultimate-Storm

I had this error happen suddenly after I was running the Node.js (FFI) version of Vosk fine for more than a month.

After a thorough investigation, I found the cause!

It turns out that Anaconda adds ~\anaconda3\Library\mingw-w64\bin to system path by default.

Depending on your installation, this directory may contain versions of the following DLLs, that could be incompatible with Vosk's:

libstdc++-6.dll
libwinpthread-1.dll

After rolling back an anaconda update for the scipy package, which added the packages m2w64-gcc-libs-5.3.0-7 and m2w64-gcc-libs-core-5.3.0-7, containing an incompatible version of the above DLLs, the problem got solved!

Seems like Vosk was resolving libstdc++-6.dll and/or libwinpthread-1.dll to the version from the anaconda path instead of from the local directory, this doesn't seem to be a desirable behavior and could break any time.

rotemdan avatar Jul 30 '22 06:07 rotemdan

D:\Renorari\Documents\Works\vosk-test\node_modules\ffi-napi\lib\dynamic_library.js:75 throw new Error('Dynamic Linking Error: ' + err); ^

Error: Dynamic Linking Error: Win32 error 127 at new DynamicLibrary (D:\Renorari\Documents\Works\vosk-test\node_modules\ffi-napi\lib\dynamic_library.js:75:11) at Object.Library (D:\Renorari\Documents\Works\vosk-test\node_modules\ffi-napi\lib\library.js:47:10) at Object. (D:\Renorari\Documents\Works\vosk-test\node_modules\vosk\index.js:84:21) at Module._compile (node:internal/modules/cjs/loader:1218:14) at Module._extensions..js (node:internal/modules/cjs/loader:1272:10) at Module.load (node:internal/modules/cjs/loader:1081:32) at Module._load (node:internal/modules/cjs/loader:922:12) at Module.require (node:internal/modules/cjs/loader:1105:19) at require (node:internal/modules/cjs/helpers:103:18) at Object. (D:\Renorari\Documents\Works\vosk-test\index.js:1:14)

Node.js v18.13.0

renorari avatar Jan 25 '23 02:01 renorari

@renorari do you have 32-bit nodejs by chance?

nshmyrev avatar Jan 28 '23 06:01 nshmyrev

I have 64 bit node and have the same issue

gabrielmicko avatar May 05 '24 21:05 gabrielmicko