- Messages
- 6
- Country

Hello,
I'm pretty inexperienced in C++ and SimConnect. So I tried to do a small first step and read a local var. With SPAD.neXt I found easily a local variable that I would like to read. But I didn't got that far.
I've read that it needs a gauge to access local vars. The problem: my console app won't compile.
This post: https://www.fsdeveloper.com/forum/t...the-outside-without-gauge.439157/#post-762356 has a lvar_interface example by ddawson. I tried to copy it:
dllmain.cpp
P3DDLLTry.h
P3DDLLTry.cpp
This works... I get a P3DDLLTry.dll and a P3DDLLTry.lib
My console app simply does:
Additional changes to my console project:
1. Properties -> VC++ Directories -> Include Directories (path to source files)
2. Properties -> VC++ Directories -> Library Directories (path to lib file)
3. Properties -> Linker -> Input -> Additional Dependencies -> P3DDLLTry.lib
Everything looks good until I click on compile:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "double __cdecl GetLVarByName(char const *)" (?GetLVarByName@@YANPEBD@Z) referenced in function main P3DDLLConsoleTry [...]\P3DDLLTry\P3DDLLConsoleTry\P3DDLLConsoleTry.obj 1
Error LNK1120 1 unresolved externals P3DDLLConsoleTry [...]\P3DDLLTry\x64\Debug\P3DDLLConsoleTry.exe 1
I thought that it might be my incompetence in C++ so I followed a very basic c++ DLL guide and it was working directly in the same project without doing a lot of things different (I didn't include the gauges.h). So I was able to call my custom function and std::cout it...
For sure some things like "FS9LINK_VERSION" look very strange but it shouldn't be a problem to compile it (in my opinion). It was also not possible for me to find any new lvar example. In general I think its horrible to find anything about LVARs in P3D. Maybe I'm searching the wrong way but it's really frustrating at the moment.
Maybe someone can help me.
Thanks a lot
I'm pretty inexperienced in C++ and SimConnect. So I tried to do a small first step and read a local var. With SPAD.neXt I found easily a local variable that I would like to read. But I didn't got that far.
I've read that it needs a gauge to access local vars. The problem: my console app won't compile.
This post: https://www.fsdeveloper.com/forum/t...the-outside-without-gauge.439157/#post-762356 has a lvar_interface example by ddawson. I tried to copy it:
dllmain.cpp
C++:
#include "pch.h"
#include "P3DDLLTry.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
PPANELS Panels = NULL;
void FSAPI DLLStart(void)
{
if (NULL != Panels)
{
ImportTable.PANELSentry.fnptr = (PPANELS)Panels;
}
}
void FSAPI DLLStop(void)
{
}
GAUGESIMPORT ImportTable =
{
{ 0x0000000F, (PPANELS)NULL },
{ 0x00000000, NULL }
};
GAUGESLINKAGE Linkage =
{
0x00000013,
DLLStart,
DLLStop,
0,
0,
FS9LINK_VERSION,
{
0
}
};
C++:
#pragma once
#include "gauges.h"
double GetLVarByName(PCSTRINGZ lvname);
double GetLVarByID(ID lvID);
P3DDLLTry.cpp
C++:
#include "pch.h"
#include "P3DDLLTry.h"
double GetLVarByName(PCSTRINGZ lvname)
{
//checks for a valid string
if (lvname == 0) return 0.;
if (strlen(lvname) == 0) return 0.;
ID i = check_named_variable(lvname);
return get_named_variable_value(i);
}
double GetLVarByID(ID lvID)
{
return get_named_variable_value(lvID);
}
My console app simply does:
C++:
#include <iostream>
#include <P3DDLLTry.h>
int main()
{
std::cout << "Hello World!\n" << std::endl;
std::cout << GetLVarByName("TEST");
}
1. Properties -> VC++ Directories -> Include Directories (path to source files)
2. Properties -> VC++ Directories -> Library Directories (path to lib file)
3. Properties -> Linker -> Input -> Additional Dependencies -> P3DDLLTry.lib
Everything looks good until I click on compile:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "double __cdecl GetLVarByName(char const *)" (?GetLVarByName@@YANPEBD@Z) referenced in function main P3DDLLConsoleTry [...]\P3DDLLTry\P3DDLLConsoleTry\P3DDLLConsoleTry.obj 1
Error LNK1120 1 unresolved externals P3DDLLConsoleTry [...]\P3DDLLTry\x64\Debug\P3DDLLConsoleTry.exe 1
I thought that it might be my incompetence in C++ so I followed a very basic c++ DLL guide and it was working directly in the same project without doing a lot of things different (I didn't include the gauges.h). So I was able to call my custom function and std::cout it...
For sure some things like "FS9LINK_VERSION" look very strange but it shouldn't be a problem to compile it (in my opinion). It was also not possible for me to find any new lvar example. In general I think its horrible to find anything about LVARs in P3D. Maybe I'm searching the wrong way but it's really frustrating at the moment.
Maybe someone can help me.
Thanks a lot
