我有一個本地插件,它在解壓後的電子應用程序上使用openSSL庫。 在Windows 10它的工作原理,並在Windows 7中它不工作,我收到這樣的:電子原生插件在窗口上失敗
Error: The specified module could not be found.
\\?\C:\Program Files (x86)\AppX Player\resources\app\src\addon\foo.node
at Error (native)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:167:20)
at Object.Module._extensions..node (module.js:568:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:167:20)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Program Files (x86)\AppX Player\resources\app\s
rc\addon\index.js:11:3)
我指定一個窗口IA32架構的電子和我重建它類似如下:
node-gyp rebuild --target=1.3.1 --arch=ia32 --dist-url=https://atom.io/download/atom-shell --verbose
該文件的binding-gyp如下所示,並基於this。它使用OpenSSL靜態庫
{
"targets": [
{
"target_name": "addon",
"sources": [
"./src/encryptor.cpp" ,
"./src/EncryptorHandler.cpp",
"./src/SetupHandler.cpp",
"./src/RC4Handler.cpp",
"./src/HardwareInfoHandler.cpp",
"../Encryptions/RC4.cpp",
"../Encryptions/AES.cpp",
"../Encryptions/utils.cpp",
"../oggEncDec/src/FileHandler.cpp",
"../oggEncDec/src/OGGSelectiveEncryptor.cpp",
"../machineIdentification/common.cpp"
],
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
'cflags': ['-fexceptions'],
'cflags_cc': ['-fexceptions -Wall -Wextra -Wconversion'],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"../"
],
'conditions': [
['OS=="linux"', {
"sources": [
"../machineIdentification/linuxHardwareInfo.cpp"
],
'libraries': [
'-lcrypto',
],
}
],
['OS=="mac"', {
"sources": [
"../machineIdentification/macHardwareInfo.cpp"
],
'libraries': [
'-lcrypto',
],
}],
['OS=="win"', {
'msvs_settings': {
'VCCLCompilerTool': {
'AdditionalOptions': [ '/EHsc' ],
'ExceptionHandling': 1
}
},
"sources": [
"../machineIdentification/windowsHardwareInfo.cpp"
],
'conditions': [
# "openssl_root" is the directory on Windows of the OpenSSL files.
# Check the "target_arch" variable to set good default values for
# both 64-bit and 32-bit builds of the module.
['target_arch=="x64"', {
'variables': {
'openssl_root%': 'C:/OpenSSL-Win64'
},
}, {
'variables': {
'openssl_root%': 'C:/OpenSSL-Win32'
},
}],
],
'libraries': [
'-l<(openssl_root)/lib/libeay32.lib',
],
'include_dirs': [
'<(openssl_root)/include',
],
}]
]
}
]
}
以防萬一它是一個DLL丟失(這不應該是因爲我是連接靜態庫),我增加了OpenSSL的DLL上的同一水平可執行程序。還有什麼可能導致這種行爲?
編輯 安裝OpenSSL的二進制文件做它的工作原理,我認爲靜態鏈接會照顧的那個,所以我不會依賴於外部DLL的
編輯2 一切想如果我可以得到解決打包靜態庫並將其捆綁到「.node」文件中。在.node文件中使用dependency walker會告訴我它需要dll,而我需要的是爲它提供dll代碼。
每個OpenSSL配置都不同。一套'CFLAGS'和'CXXFAGS'不會。它尤其適用於32位和64位應用程序。另請參閱[在OS X上構建多元OpenSSL](http://stackoverflow.com/q/25530429)。不要擔心OS X位;相反,關注像BIGNUMs這樣的東西的差異。快速/骯髒的解決方案:爲每個平臺運行'./configure',然後複製'CFLAGS'。配置顯示'CFLAGS',所以它很容易複製/粘貼。 – jww
請看看並嘗試理解它,謝謝! – FabioCosta
我檢查與依賴沃克,當我編譯.node它帶有一個dll依賴項,有沒有辦法「複製」鏈接的代碼,所以它被編譯在.node旁邊,我不需要任何DLL? – FabioCosta