EvenAR / node-simconnect

A cross platform SimConnect client library for Node.JS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unresolved external symbol

bogdanrau opened this issue · comments

I've been trying to get this to work within a node/vue/electron environment, but every way I try to rebuild this, I end up getting an error. This is as far as I've been able to get to, using:

node-gyp rebuild --target=11.0.5 --arch=ia32 --dist-url=https://electronjs.org/headers

I get the error below:

simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_RequestSystemState@12 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build\
node_simconnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_AddToDataDefinition@28 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build 
\node_simconnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_GetNextDispatch@12 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build\nod 
e_simconnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_RequestDataOnSimObjectType@20 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnec 
t\build\node_simconnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_Open@24 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build\node_simconnec 
t.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_Close@4 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build\node_simconnec 
t.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_RetrieveString@20 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build\node 
_simconnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_FlightLoad@8 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build\node_simc 
onnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_SetDataOnSimObject@28 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build\ 
node_simconnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_SubscribeToSystemEvent@12 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\bu 
ild\node_simconnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_MapClientEventToSimEvent@12 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\ 
build\node_simconnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_TransmitClientEvent@24 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build 
\node_simconnect.vcxproj]
simconnect_session.obj : error LNK2001: unresolved external symbol _SimConnect_RequestDataOnSimObject@36 [C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\bu 
ild\node_simconnect.vcxproj]
C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect\build\Release\node_simconnect.node : fatal error LNK1120: 13 unresolved externals [C:\Users\user\Documents\ 
VueJS\project\node_modules\node-simconnect\build\node_simconnect.vcxproj]
gyp ERR! build error 
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\user\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=11.0.5" "--arch=ia32" "--dist-url=https://electronjs.org/headers"
gyp ERR! cwd C:\Users\user\Documents\VueJS\project\node_modules\node-simconnect
gyp ERR! node -v v14.15.4
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok

I also tried changing the arch to x64, which builds successfully, but then when I run the app, I get:

ERROR  Failed to compile with 1 error                                                                                                                                     11:38:08 AM
This relative module was not found:

* ./bin/win_ia32/node_simconnect in ./node_modules/node-simconnect/index.js

Am I completely missing something here? This was done using the refactor branch btw.

I tested using node v15.3.0. There's a couple issues but it seems to work.

For linking to the FS2020 SDK, you must build x64. You could almost definitely link to the FSX/P3D SDK and still get most/all of the features. However the MSFS SDK that I downloaded does not have a 32-bit .lib.

This command may be used in place of npm rebuild:
npx node-gyp configure rebuild --msvs_version=2019 --arch=x64

After successful build you must copy SimConnect.dll to \build\Release manually.

The directory is cleaned after every rebuild, so be careful. Module not found may not talking about the .node file itself but rather about a required dependency on an unavailable SimConnect.dll.

Then fix up index.js on line 7 because this relative path isn't working for this scenario where the project is included by ../../ pathing.

nodeSimconnect = require(`c:/src/node-simconnect/build/Release/node_simconnect`);

Then start sim and
node .\examples\nodejs\example.js

image

I'm closing this as the new version works natively with Electron (no custom build needed).