Archived

This topic is now archived and is closed to further replies.

Philipp Ringler CFI

compiling for SimConnect on other compiler than MSVC++

Recommended Posts

Hi folks,i'm wondering if it is possible to build a simconnect application on anything else then Microsoft Visual Studio. I'm not confident in using this IDE and prefer to do most of the things myself.So normally, if you develop for an off-the-shelf library, all you have to do is specify the right include path, configure the linker to link against the lib and there you go. If i try to build a simconnect app using a QT-defined makefile and compiling with gcc i get a lot of errors:

In file included from c:/Programme/Microsoft Visual Studio 9.0/VC/include/excpt.h:22,from c:/Programme/Microsoft SDKs/Windows/v6.0A/Include/windows.h:151,from ThrottleControl.cpp:11:c:/Programme/Microsoft Visual Studio 9.0/VC/include/crtdefs.h:530: error: redeclaration of C++ built-in type `short'c:/Programme/Microsoft Visual Studio 9.0/VC/include/crtdefs.h:574: error: `__int64' does not name a typec:/Programme/Microsoft Visual Studio 9.0/VC/include/crtdefs.h:582: error: `__time64_t' does not name a typeIn file included from c:/Programme/Microsoft SDKs/Windows/v6.0A/Include/winnt.h:105,from c:/Programme/Microsoft SDKs/Windows/v6.0A/Include/windef.h:177,from c:/Programme/Microsoft SDKs/Windows/v6.0A/Include/windows.h:155,from ThrottleControl.cpp:11:c:/Programme/Microsoft SDKs/Windows/v6.0A/Include/basetsd.h:79: error: `__int64' does not name a typec:/Programme/Microsoft SDKs/Windows/v6.0A/Include/basetsd.h:83: error: `__int64' does not name a typec:/Programme/Microsoft SDKs/Windows/v6.0A/Include/basetsd.h: In function `void* PtrToPtr64(const void*)':c:/Programme/Microsoft SDKs/Windows/v6.0A/Include/basetsd.h:361: error: expected primary-expression before "void"

and so on. Includes are#include <windows.h>#include <tchar.h>#include <stdio.h>#include <strsafe.h>#include "SimConnect.h"I configured the include paths to:"C:\Programme\Microsoft SDKs\Windows\v6.0A\Include" and "C:\Programme\Microsoft Visual Studio 9.0\VC\include"so what is missing here? Apparently some windows-specific typedefines are missing, because some include failed. Has anyone tried doing this yet?

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Some observations from my end having attempted this in a prior life. I returned home battered and beaten by C++ forces greater than I wanted to conquer. If you want a challenge, that's a great way to start.1) the devil is in the details and every compiler implements its very own interpretation of standards - in other words, there is a standard, everyone claims they abide by the standard, and every compiler interprets things differently. Web browsers anyone? Same with compilers, and standard the libraries are not - unless you stick to pure K&R, in which case, that works but that is very, very simple and compiling for simconnect is a bit beyond the average "hello world" and stdio.h. While the compiler itself you may be able to get by, the pre-processor is a different beast altogether and is usually full on non standard constructs thanks to #pragmas and the deliciously named "extensions" that can be turned off, yet nothing works out of the box when they are. The files in the SDK are setup to work with Visual Studio's C compiler, so you will need to "fix" any extension or behaviors unique to that compiler. That means, a lot of header file changes, as all the header files are designed to work in Visual Studio, not by another compiler.2) Simconnect is designed to use the MSVC runtime libraries. Some calls, especially the platform related ones starting with __ are specific to MS' version of the runtime libraries and win32. Indeed, in the simconnect manifest there is a dependency to MSVCRT 8.0 so including the simconnect.lib file may likely give you a linker error if you use a different set. I don't believe you can link .obj or .lib files from one compiler with another because of internal format differences. It may compile yet won't link.3) You likely can load compiled simconnect.dll but you will need to use your own interface to its functions to avoid using the .lib.What I suggest you do is use a different environment but use the command line C++ compiler from Microsoft. This way, you can get away with the extensions, the preprocessor will understand the header files, yet you can use tools you are more familiar with for make , etc...Hope this helps, and good luck.Etienne

Share this post


Link to post
Share on other sites

From the error messages, it seems your problem is in building a Windows application, not a SimConnect one - the error messages are being thrown out by Window.h, which is included before SimConnect.h. Have you ever built a windows app under this build environment before? If so, compare your settings and include statements, cause something seems broken.If you haven't done so yet in this environment, I would suggest writing a Hello, World program for windows using these tools, and if you can't get that to work, try the support forums for GCC/<Whatever other build tools you are using>.Or, the Visual Studio Express line of products are free, and actually work correctly in a windows environment (the only environment they are designed for, so if you are writing an app that will only ever run under windows, doesn't it make sense to use tools that specifically target that environment :-> ).Tim

Share this post


Link to post
Share on other sites

Okay, this sounds almost as bad as i expected :(As you said, the "standard" is quite different between two interpretations. But WHY is it, that the MS "interpretation" is ALWAYS different from ALL OTHERS ??? The same is for your example with web-browsers - done that stuff a few years ago. Again the one that didn't work as the standard describes was - you guessed it - MSIE.And now the same sh*t - different day!Why the f*ck is all the world getting along with 32bit unsigned integers, and only microsoft uses their queer DWORDs? By the way, a DWORD on XP 64 is actually a half word, not a double one. Consistency???And what about all these LPCWSTRWTFSNAFUBAR*@%$!^^#? What the heck do these MS p***** think we've got a standard library for ? Okay, all agression blown off now. Let's see how we get this thing to work.Your solution sounds reasonable. Code with Qt-Creator, let qmake create a vs-project and compile there. @Tim:Yes, i can build a hello world on windows :). From a qmake created makefile, compile with minGWs g++. Links. Runs.I found the problem starts, when i include strsafe.h. It is not shipped with MinGW, so i have to edit the include path. The problem then is, i have yet to find out how to trick the makefile creator to not use the standard minGW include-paths. What actually happens is, when i type #include <windows.h> it includes c:\Mingw\include\windows.h instead of C:\Programme\Microsoft SDKs\Windows\v6.0A\Include\windows.h- Even worse, if i trick him to use the latter, it tries to include sdkdkver.h, stralign.h, etc from minGW again and fails. I have still to figure out how to setup the include path lookup order right. If i write the makefiles myself, this works, but writing makefiles in larger projects becomes a real pain, so i use qmake everwhere.And for the platform thing - what i'm writing is something that should compile everywhere, and the makefile-creator should see "Ah, we're on windows, so compile the Simconnect part of it too". Works great with qmake, apart from the include-path issues.EDIT:And speaking of DWORDs, why is it, when they are in fact unsigned 32bit integers, that the simconnect.h reads static const DWORD INITPOSITION_AIRSPEED_CRUISE = -1; // aircraft's cruise airspeedWhat part of the unsigned did i not understand??And for another thingTHERE IS NO SUCH THING as a "static enum" period.another EDIT:Strangely enough, i can build an FSUIPC application (that also uses windows.h and DWORDs) with minGW without further ado. So what's the big mystery with SimConnect?And speaking of mysteries, why do we have to bother with SimConnect at all? As for as i understand the SDK all it does is communicate with FSX using IPv6 packets. Then why don't they just publish how to contruct and decontruct this packets and let us do the communication job ourselves? Is FlightSim Data so critical for the homeland security that it has to be encrypted on the way to Active Sky, FSMap or whatever?

Share this post


Link to post
Share on other sites

__int64 is Microsoft specific and has no ANSI equivalent.http://msdn.microsoft.com/en-us/library/29dh1w7z(VS.80).aspxI believe that __time64_t is defined in time.h as:#ifndef _TIME64_T_DEFINED#if _INTEGRAL_MAX_BITS >= 64typedef __int64 __time64_t; /* 64-bit time value */#endif#define _TIME64_T_DEFINED#endif__time64-t is typedef'd to __int64 (see above) and it isn't defined unless _INTEGRAL_MAX_BITS is 64 or greater. _INTEGRAL_MAX_BITS is also Microsoft specific.http://msdn.microsoft.com/en-us/library/b0084kay(VS.80).aspx

Share this post


Link to post
Share on other sites

I don't know if this will help, but in December of 2006 I tested Simconnect with Borland C++ turbo, and got some results:http://webpages.charter.net/ludowr/Borland_SimConnect.ziphttp://webpages.charter.net/ludowr/Borland_RequestData.zipBorland Turbo is free, and a decent alternative to the MS Visual Studio Express ( if you don't like that free environment ).http://www.turboexplorer.com/cppIf you still perfer your system, perhaps my Borland examples can still help.There are Simconnect adaptations for Java, and Delphi, .NET, and VB6, I believe... so I'm sure this is possible.Dick

Share this post


Link to post
Share on other sites

You know, I'm glad you mention Turbo C++, I learned to code in Turbo Pascal, grew up to Turbo C++ and then Borland C++ and then JBuilder, fond memories there... I'm now on VS 2008, C# and .NET mostly (except for my gauge work, still largely C++). Turbo Pascal will always have a special place because it was the only environment at the time that had both syntax highlighting and a debugger, items that my mainframe based colleagues were drooling over while they were still trying to figure out how to use the venerable vi for their source files (vi is to me almost as straightforward as reverse polish notation XML lol).Etienne

Share this post


Link to post
Share on other sites

Hi Etienne.This is the full-blown RAD Borland environment. But you can only have C++ or Delphi... not both. Either can produce executables and DLLs that require no runtime environments. 32-bit only.It does have an advantage over the VS2008express C++ in that it has the RAD ( or forms ) environment. I'm not a big fan of C++, but I have used Delphi, and I found it very easy to use, much like C#, but it creates 32-bit binary code just like C++.I should say C# is a lot like Delphi, as the ,Net environment has it's roots in Delphi.Regardless, this Borland product can make gauges, DLLs, and programs that interact with Simconnect or FSUIPC.Dick

Share this post


Link to post
Share on other sites
I don't know if this will help, but in December of 2006 I tested Simconnect with Borland C++ turbo, and got some results:http://webpages.charter.net/ludowr/Borland_SimConnect.ziphttp://webpages.charter.net/ludowr/Borland_RequestData.zipBorland Turbo is free, and a decent alternative to the MS Visual Studio Express ( if you don't like that free environment ).http://www.turboexplorer.com/cppIf you still perfer your system, perhaps my Borland examples can still help.There are Simconnect adaptations for Java, and Delphi, .NET, and VB6, I believe... so I'm sure this is possible.Dick
I can only get a 14 day trial of turbo Explorer from the site. Is it possible to get a full version?

Share this post


Link to post
Share on other sites
I can only get a 14 day trial of turbo Explorer from the site. Is it possible to get a full version?
I don't think they changed their policy.I have the Turbo C++ and it's a trial, but the expiration is in zero days...They have a download page... then you go to a signin page, and that page states:"You have selected "Turbo C++ 2006 Explorer". Your trial period is 0 days from the time you install the product. Please log-in or create and account so we can email your trial activation code."That would indicate the trial lasts forever, as it was in the past.I signed in ( my old Borland signin worked fine ) and When I checked my email about 10 seconds later, it had this message:THIS IS AN AUTO-GENERATED MESSAGE - PLEASE DO NOT REPLY TO THIS MESSAGETurbo C++ 2006 Explorer EditionSerial Number: xxx-xxxxxx-xxxxxx-xxxxAuthorization Key: xxx-xxxLogin Name: XXXXXXXFirst Name: RichardLast Name: LudowiseThis is a resend of your trial activation information. Please register your Embarcadero product / trial using the serial number provided.Thank you for choosing Embarcadero award-winning products.Kind regards,The Embarcadero TeamNothing has been said about a 14 day trial in any of this. You did get the explorer version and not the pro version?++++++++++++If the MS VS C++ 2008 version had the RAD forms environment, I wouldn't bother, but I like the ease of forms, and you need the .NET for forms in the Express versions, so I end up using C#.Dick

Share this post


Link to post
Share on other sites

I downloaded and tried it. Although it's free I couldn't get on with the GUI interface and have reverted to my 10 year-old Borland C++ Builder 4 and uninstalled it. Also, I found the help system much less helpful and slower than the old one.

Share this post


Link to post
Share on other sites

I want to reiterate what Beatle said.... VC++ is free and so is the documentation... you might want some of the warning/error messages that it provides that are specifically target for the Windows environment...... a lot of the standard C libraries have been deprecated or banned... save yourself the trouble.

Share this post


Link to post
Share on other sites