• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Problems compiling

Messages
368
Country
unitedkingdom
I'm trying to compile a SimConnect utility in VC++ 2008. It's basically a mash up of the Request Data sample and some execute_calculator_code to try and write some information back to an XML gauge.
The SimConnect part works fine on its own, but as soon as I enter the execute_calculator_code I get a :- error LNK2001: unresolved external symbol _ImportTable error. I've tried adding the code to compile as a DLL with no joy, actually the only SimConnect DLL I've managed to successfully compile was the sample I downloaded from one of the MS blogs, and I can't even copy that code into another project without getting errors.
I'm guessing from this I haven't got my VC++ set up properly but I've been unable to find any guides or tutorials to doing this, does anyone know of any?
 
execute_calculator_code() only works from within a C gauge, not a standalone SimConnect client application.

Si
 
execute_calculator_code() only works from within a C gauge, not a standalone SimConnect client application.

Si

By "within a C gauge", I assume you mean any in-process simconnect "dll application", ( not necessarily a Gauge) as opposed to an externally connecting simconnect "exe application". ?

When I read the post I had assumed he was writting a C++ dll simconnect application, in which execute_calculator_code() should work.

Geoff_D
 
When I read the post I had assumed he was writting a C++ dll simconnect application, in which execute_calculator_code() should work.

Yes, it should if he uses the PANELS pointer declared as an external and filled in by SimConnect, and defines "execute_calculator_code" as "panels->execute_calculator_code", but if he has references to ImportTable then it sounds very much like he has some FS9 code -- and maybe the FS9 Gauges.h file?

Regards

Pete
 
execute_calculator_code() only works from within a C gauge, not a standalone SimConnect client application.

Si

This is obviously the bit where I sound stupid, but how do I make the compiler tell the difference and what is it? I'm using the fsxgauges_sp2.h, I've heard of FS9 but it's not really my thing!

I think I've got it set up to compile DLLs by copying the samples, and without the execute_calculator_code it does.

As a quick summary, I've written a SimConnect exe that gets the position of any shipping within a given range and then displays it's position as a range and bearing. What I'd like to do is have it run as a gauge and then pass the information to an XML gauge to display it along with the GPS terrain info to give a surface search radar and allow the user to control gain (so only contacts above a given size are displayed) and possibly lock onto a contact to give a steer in the HUD/nav system.
 
Last edited:
I'm using the fsxgauges_sp2.h

I can't find that file (where did you get it?), but in the original SDKs for FSX, Microsoft did still issue the FS9-style gauges.h, and possibly your code is #including it? In that header file the routine you are calling was still defined as:

#define execute_calculator_code (ImportTable.PANELSentry.fnptr->execute_calculator_code)

which would therefore give you the ImportTable reference. Try finding it and replacing it with

#define execute_calculator_code (panels->execute_calculator_code)

Assuming you've define "panels" as described in the SimConnect documentation, that should compile.

Regards

Pete
 
Last edited:
Pete, thanks for that, I got the fsxgauges_sp2.h from Dai Griffiths C gauge creation tutorial, but it sounds like that was unnecessarily complicating things. I haven't been defining 'panels' which is probably where I'm having snags!

Once my post-Christmas do hangover clears up I'll investigate. Probably February then!
 
I got the fsxgauges_sp2.h from Dai Griffiths C gauge creation tutorial, but it sounds like that was unnecessarily complicating things.

I've downloaded that kit and looked at that file, and it is essentially the same as the Microsoft issued one. I'm not sure what he's changed. But it is for use in a Gauge, not an SimConnect-loaded DLL. They don't link to FS in the same way -- Gauges have ImportTable and Linkage exports, and invoke mechanisms through those which chain them into a calling sequence for updates.

Just find the line I mentioned and change it as I suggested (and any other PANELS calls listed there you also want to use), and provided "Panels" is defined correctly you should be okay.

[STOP PRESS: It should be "Panels" with a capital P, not "panels" as I stated earlier].

Really Microsoft's SDK isn't aimed at folks wanting to use the PANELs calls from a SimConnect DLL, though SimConnect does provide the pointer in case you do.

I haven't been defining 'panels' which is probably where I'm having snags!

Ah, no ... that will be your NEXT snag! ;-). and in fact I've just searched the SimConnect documentation and it doesn't appear to mention it!

Just put this in your main source file, after the include of the gauges header:

EXTERN_C __declspec(dllexport) PANELS *Panels = NULL;

remembering, again, that it is "Panels" not "panels". The PANELS typedef in the header file you are using is okay.

Regards

Pete
 
In fact, I believe this is the only way to run XML from code - and it has to be in-process. It works well, I used the panel interface within a simconnect dll for the message lines before simconnect started to provide this functionality. I also use the calculator code function to get variables that are only in XML, and having this ability makes coding vastly simpler if you need to get a synchronous value, or set a value. It would be nice for all the gauge/panel API functionality to be incorporated directly in simconnect calls to avoid mixing but hey, this is is leaps and bounds better than the world pre-simconnect!

Etienne
 
Last edited:
Just to clarify things, is it possible to have a C gauge that uses simconnect and can update XML variables? Or will I have to write a dll with an entry in the dll.xml file? My preference is for the former as it involves less thinking on the part of the end user when installing it.
 
Yes, it is.

Put your SimConnect connection code in the pre-initialise section of the gauge callback's switch section.

Put the disconnection code in the callback's exit section.

You can also set up an event trap on the frame rate, which you can use if you need to calculate things more often than the 18 Hz gauge update rate.

On thing to bear in mind is that gauges don't run until the VC or cockpit panel that includes them is displayed. You could get around this by creating a panel that is flagged as always on in the panel.cfg, put your gauge on that, but don't use any background panel or gauge graphics.

That way users can load your aircraft in any view, including external, and your simconnect code will work straight away.

Another thing to remember is that if you put the same gauge on two panels, or in both the VC and 2D cockpits, then that code will get run twice, which probably isn't what you want.

From within your SimConnect callback or gauge callbacks you can use execute_calculator_code() to transfer between XML and C variables.

There is no need to put entries in the dll.xml file to do this.

Si
 
Last edited:
Simon, many thanks, that was exactly what I didn't know I needed to know! I'm tied up with other stuff this week but I hope to get this cracked during my Christmas break, I'll probably end up using this to simulate a lot more of the advanced systems in the aircraft once it's working.
 
Back
Top