Closed yerkeyzet closed 1 year ago
You may need to run the following, if nw does not install automatically:
npm install nw@0.45.5-sdk
It happens on Windows only. Please feel free to try workarounds mentioned in napi#269, until the solution found.
Thanks a lot for your feedback.
I went through the topic and found that one of the add-on developers could resolve this problem in his add-on a couple of days ago. I have asked him to update on the root cause, lets wait and see if it is applicable for node-rfc.
He answered in the thread above, please have a look if you see any hints...
I tried step 2 from workaround below, but no result. Can you apply step 1 from your side? _1. Add set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DELAYLOAD:node.exe" ) to the Windows version of our native module in CMakeLists.txt
I also opened a new issue on their page based on your message, as the topic above was already closed and there is no guarantee that they will consider further activities of a closed topic.
I tried step 1 alone and it did not help but both steps together could eventually make a difference. Where exactly did you add the step 2 ?
The step 1 requires one line insert into CMakeLists.txt
, after LTCG parameter at line 173:
target_link_options(${PROJECT_NAME} PUBLIC
/NXCOMPAT
/SWAPRUN:NET
/OPT:REF
/NOLOGO
/LTCG
/DELAYLOAD:node.exe
)
You can add the line and build sapnwrfc.node from source, running npm run prebuild
.
Here the Windows build with step 1 only: sapnwrfc.node.zip
1) I put win_delay_load_hook.cc
to these locations:
npm install node-gyp -g
C:\Users\Yerkebulan\AppData\Roaming\npm\node_modules\node-gyp\src\
C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\
2) I modified C:\Storage\code\electron-quick-start_RFC\node_modules\node-rfc\CMakeLists.txt
as you said, then ran npm run prebuild
under C:\Storage\code\electron-quick-start_RFC\node_modules\node-rfc\
, but error still exists.
3) I downloaded your sapnwrfc.node
file and placed it to C:\Storage\code\electron-quick-start_RFC\node_modules\node-rfc\lib\binding\
But still it gives me an error :(
What am I doing wrong?
My Node,js version is 14.2.0 Electron 8.2.5
I also tried with Node 12.13.0 as you do -- but still an error.
My Windows 10 version is 1909 I compile with Visual Studio 2019
What is your VS version?
I am using VS2019 and used Node 12.13.0 because that version used in Electron 8.
Why NW.js is mentioned if initial/top comment, when the issue is about Electron?
I first faced this issue in NW.js, then tried in Electron and got same error there.
For now both of them don't work for me.
Here the Windows build with step 1 only: sapnwrfc.node.zip
I realized that you attached a build only with step 1. Can you please attach a build that worked for you on Windows 10 (after both steps applied)?
Sorry, no build worked for me on Windows and I did not test NW.
Please have a look into Electron documentation and try if any of methods described there eventually work for you?
None of them worked for me and I asked prebuild and Electron teams for help:
I've been struggling with this issue for about a week and have tested all possible methods including this...
Ok, thanks for contacting with other teams! I hope we will manage to create SAP RFC desktop apps with JS.
I'm getting the same error with zeit/pkg. Any updates on this? or any workarounds?
Hi,
Unfortunately no updates so far...
Also getting the error with zeit/pkg.. are there any updates?
Edit: I think i could solve it, atleast not getting errors at the moment
Placed win_delay_load_hook.cc under ./src Added /DELAYLOAD:node.exe at line 183 of CMakeLists.txt Added src/win_delay_load_hook.cc at line 99
Here is a gist of the updated files
Tested again on Windows 10, with SAP NWRFC SDK 7.50 PL7 and node-rfc 2.3.0 and the same issue occurs.
The Process Monitor shows SDK libraries are found and for some reason still not loaded:
Although it works on Linux and MacOS, the SAP NWRFC SDK is not supported on Electron platform. You may create SAP feature request for SAP Cloud Platform Connectivity Service
subtopic of the SAP Cloud Platform - Integration Suite.
If you create the request, please share the link here.
I solve this by
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" )
I use cmake-js CMAKE_SHARED_LINKER_FLAGS equals /DELAYLOAD:node.exe
I install my native module runtime to electron
and works fine on windows now.
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${OS_LIBS}
while OS_LIBS contains "DelayImp.lib"
CMAKE_JS_LIB contains node.lib
also follow cmake Include N-API wrappers section
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR} )
so I think here is 3 key points:
/DELAYLOAD:node.exe
node.lib
these mentioned in electron's document and cmake-js's readme but they don't provide a full example.
also I'd mention I literally set add_compile_definitions(NAPI_VERSION=6)
since electron is combination of napi and node
@bung87 just to confirm: you getting node-rfc running in Electron?
I keep getting the error message A dynamic link library (DLL) initialization routine failed
.
Looks like https://github.com/SAP/node-rfc/blob/main/CMakeLists.txt has already partly been adapted based on your remarks?
Could you though provide a working example of CMakeLists.txt
to successfully compile the sapnwrfc.node
binding file?
My Node.js environment:
{
node: '14.18.0',
v8: '8.4.371.23-node.84',
uv: '1.42.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.17.2',
modules: '83',
nghttp2: '1.42.0',
napi: '8',
llhttp: '2.1.3',
openssl: '1.1.1l',
cldr: '39.0',
icu: '69.1',
tz: '2021a',
unicode: '13.0'
}
My Electron environment (v15.1.2):
{
"platform": {
"name": "win32",
"arch": "x64",
"release": "10.0.19043"
},
"env": {
"SAPNWRFC_HOME": "C:\\Users\\Zefau\\Projects\\dc-dashboard\\build\\nwrfcsdk",
"RFC_INI": "",
"nwrfcsdk_lib_on_path": true
},
"versions": {
"node": "16.5.0",
"v8": "9.4.146.18-electron.0",
"uv": "1.41.0",
"zlib": "1.2.11",
"brotli": "1.0.9",
"ares": "1.17.1",
"modules": "98",
"nghttp2": "1.42.0",
"napi": "8",
"llhttp": "6.0.2",
"openssl": "1.1.1",
"icu": "69.1",
"unicode": "13.0",
"electron": "15.1.2",
"chrome": "94.0.4606.71"
}
}
Could you please try with node-rfc@3.0.0-rc.2
addition: and with updated test case: SAP-samples/node-rfc-samples/frameworks/electron-quick-start
Electron is supported as of node-rfc@3.1, also on Windows
Hi Team,
There is an issue when running node-rfc with NW.js or Electron on Windows 10. After running "npm start" it throws an error: Uncaught Error: A dynamic link library (DLL) initialization routine failed. \?\C:\Storage\code\nwjs-hands-on\node_modules\node-rfc\lib\binding\sapnwrfc.node
It is easy to reproduce, just download my ready to run codes, npm install, and npm start - you will get the error in Dev tools console. nwjs-hands-on.zip
I have tried rebuilding node-rfc with MSVS 2012, 2013, 2015, 2017, 2019 - none of them helped. Command I used is: npm install node-rfc --build-from-source --runtime=node-webkit --target=0.45.5 --target_arch=x64
On the other hand node-rfc works perfectly with Node.js app on the same Windows 10 machine.
What exact Visual Studio version do you use to compile C/C++ codes for this module? Any ideas how to proceed further?