LNK2019 Compile Issues

cybanski
Posts: 8
Joined: Wed Jan 18, 2012 12:50 pm

LNK2019 Compile Issues

Postby cybanski » Fri Apr 24, 2020 1:54 pm

Hello,

I am trying to compile a simple CLR C++ using WinForms that displays live information on the screen in a small window. RequestData.cpp was used as an example, and I have had good success with that, but it sends the data to the console rather than a window. I have also been able to successfully compile a CLR C++ WinForm that draws a simple window.

There are issues trying to combine the two. The SimConnect_Open(&BFC, "Request Data", NULL, 0, 0, 1) call at the end is where the problems start. If I comment out this line, the code compiles no problem. It could be a linking problem, but I have triple-checked all the SDK setup steps. Does anyone have experience with C++ WinForms and SimConnect?

Thanks

Code: Select all

Code Description LNK2019 unresolved external symbol __imp_SendMessageW referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z) LNK2019 unresolved external symbol __imp_PostMessageW referenced in function "public: virtual void __cdecl ClientClient::Close(enum CLIENTERROR,unsigned long)" (?Close@ClientClient@@UEAAXW4CLIENTERROR@@K@Z) LNK2019 unresolved external symbol __imp_FindWindowW referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z) LNK2019 unresolved external symbol __imp_GetWindowThreadProcessId referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z) LNK2019 unresolved external symbol __imp_RegCloseKey referenced in function "bool __cdecl GetRegistryPort(bool,wchar_t *)" (?GetRegistryPort@@YA_N_NPEA_W@Z) LNK2019 unresolved external symbol __imp_RegOpenKeyExW referenced in function "bool __cdecl GetRegistryPort(bool,wchar_t *)" (?GetRegistryPort@@YA_N_NPEA_W@Z) LNK2019 unresolved external symbol __imp_RegQueryValueExW referenced in function "bool __cdecl GetRegistryPort(bool,wchar_t *)" (?GetRegistryPort@@YA_N_NPEA_W@Z) LNK2019 unresolved external symbol __imp_CoTaskMemFree referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z) LNK2019 unresolved external symbol SHGetKnownFolderPath referenced in function "enum CC_RESULT __cdecl CommClient_Open(void * *,unsigned long)" (?CommClient_Open@@YA?AW4CC_RESULT@@PEAPEAXK@Z) LNK1120 9 unresolved externals

Code: Select all

#include "MyForm.h" #include <Windows.h> #include <tchar.h> #include <stdio.h> #include "SimConnect.h" #include <strsafe.h> using namespace System; using namespace System::Windows::Forms; int quit = 0; HANDLE hSurface = NULL; HANDLE BFC = NULL; struct Struct1 { char title[256]; double kohlsmann; double altitude; double latitude; double longitude; }; enum EVENT_ID { EVENT_SIM_START, }; enum DATA_DEFINE_ID { DEFINITION_1, }; enum DATA_REQUEST_ID { REQUEST_1, }; void CALLBACK MyDispatchProcRD(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext) { switch (pData->dwID) { case SIMCONNECT_RECV_ID_EVENT: default: { SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE*)pData; switch (pObjData->dwRequestID) { //default: case REQUEST_1: { DWORD ObjectID = pObjData->dwObjectID; Struct1 *pS = (Struct1*)&pObjData->dwData; if (SUCCEEDED(StringCbLengthA(&pS->title[0], sizeof(pS->title), NULL))) // security check { printf("\nObjectID=%d title=\"%s\"\nLat=%f Lon=%f Alt=%f Kohlsman=%.2f", ObjectID, pS->title, pS->latitude, pS->longitude, pS->altitude, pS->kohlsmann); } break; } } break; } case SIMCONNECT_RECV_ID_QUIT: { quit = 1; break; } } } void testDataRequest() { HRESULT hr; SimConnect_Open(&BFC, "Request Data", NULL, 0, 0, 1); { } }

Highflyer525
Posts: 9
Joined: Wed Feb 07, 2018 8:23 pm

Re: LNK2019 Compile Issues

Postby Highflyer525 » Wed Apr 29, 2020 11:54 pm

Hi,

Yes I have a basic version working. Have you followed these instructions to the letter? https://www.prepar3d.com/SDKv5/sdk/simc ... jects.html

The LNK errors are normally caused because it can't find the library in question and resolve the symbols

Of particular importance is using VS2019, making sure your project is X64, making sure the include and library paths are included and the Simconnect.lib (or debug version) is included in the command section of the linker.

Also, you must use the debug library for debugging and the normal version for release. Sound obvious, but it will cause further errors if you try and mix them.

I've assumed you know what you're doing with visual studio, so kept it brief as the instructions are in the link provided. Let me know if there's anything you are unsure of.

Cheers,

Mark.

P.s. make sure this hasn't slipped back to X86 or Win32 whilst you're changing settings.

Image


Return to “SimConnect Interface Questions”

Who is online

Users browsing this forum: No registered users and 7 guests