visual studio 2015 & latest std

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
bovril
Posts: 8
Joined: Thu Apr 05, 2012 7:26 pm

visual studio 2015 & latest std

Post by bovril »

i'm trying to compile one of the very simple exmples but getting no where :(
is there ar step by step guide for how to configure and Visual Studio 2015 and the SDK

I'm looking to compile just simple command widnow out put and nothing else

many thanks in advance to anyone that can help
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: visual studio 2015 & latest std

Post by ronh991 »

This might help - I know it talks VS 2010 and VS2013, but the important part is the platform

http://www.prepar3d.com/forum/viewtopic ... 0&t=117397
Ron
bovril
Posts: 8
Joined: Thu Apr 05, 2012 7:26 pm

Re: visual studio 2015 & latest std

Post by bovril »

not helped at all :(

I either get lockhed.obj cant be found, simconnect.dll cant be found
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: visual studio 2015 & latest std

Post by ronh991 »

Is this C++ or C#? Don't recognise the error.
Ron
bovril
Posts: 8
Joined: Thu Apr 05, 2012 7:26 pm

Re: visual studio 2015 & latest std

Post by bovril »

c++
documentation for this product is rubbish
I'm trying to compile..

//Copyright (c) Lockheed Martin Corporation. All rights reserved.
//------------------------------------------------------------------------------
//
// SimConnect Data Request Sample
//
// Description:
// After a flight has loaded, request the lat/lon/alt of the user
// aircraft
//------------------------------------------------------------------------------

#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include "SimConnect.h"
#include <strsafe.h>


int quit = 0;
HANDLE hSimConnect = NULL;

struct Struct1
{
char title[256];
double kohlsmann;
double altitude;
double latitude;
double longitude;
};

static enum EVENT_ID {
EVENT_SIM_START,
};

static enum DATA_DEFINE_ID {
DEFINITION_1,
};

static enum DATA_REQUEST_ID {
REQUEST_1,
};

void CALLBACK MyDispatchProcRD(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
HRESULT hr;

switch (pData->dwID)
{
case SIMCONNECT_RECV_ID_EVENT:
{
SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;

switch (evt->uEventID)
{
case EVENT_SIM_START:

// Now the sim is running, request information on the user aircraft
hr = SimConnect_RequestDataOnSimObjectType(hSimConnect, REQUEST_1, DEFINITION_1, 0, SIMCONNECT_SIMOBJECT_TYPE_USER);

break;

default:
break;
}
break;
}

case SIMCONNECT_RECV_ID_SIMOBJECT_DATA_BYTYPE:
{
SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE*)pData;

switch (pObjData->dwRequestID)
{
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;
}

default:
break;
}
break;
}


case SIMCONNECT_RECV_ID_QUIT:
{
quit = 1;
break;
}

default:
printf("\nReceived:%d", pData->dwID);
break;
}
}

void testDataRequest()
{
HRESULT hr;

if (SUCCEEDED(SimConnect_Open(&hSimConnect, "Request Data", NULL, 0, 0, 0)))
{
printf("\nConnected to Prepar3D!");

// Set up the data definition, but do not yet do anything with it
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "title", NULL, SIMCONNECT_DATATYPE_STRING256);
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "Kohlsman setting hg", "inHg");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "Plane Altitude", "feet");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "Plane Latitude", "degrees");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "Plane Longitude", "degrees");

// Request an event when the simulation starts
hr = SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SIM_START, "SimStart");

while (0 == quit)
{
SimConnect_CallDispatch(hSimConnect, MyDispatchProcRD, NULL);
Sleep(1);
}

hr = SimConnect_Close(hSimConnect);
}
}

int __cdecl _tmain(int argc, _TCHAR* argv[])
{

testDataRequest();

return 0;
}
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: visual studio 2015 & latest std

Post by ronh991 »

I'm still on VS2013 so don't know if that would be the issue, but it should not.

Please copy paste the error you get. Maybe can reproduce it.
Ron
bovril
Posts: 8
Joined: Thu Apr 05, 2012 7:26 pm

Re: visual studio 2015 & latest std

Post by bovril »

as above either simconnect.dll or lockhead.obj cant be loaded on building
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: visual studio 2015 & latest std

Post by ronh991 »

Here are the steps I do:

1. create project (P3DTest) - Win32 console app - empty project
2. Copy paste the code example to a new cpp file (P3Dtest.cpp)
3. Right click on the project select properties.
4. expand C++
5. add new inc folder - in my case its F:\Program Files (x86)\Lockheed Martin\Prepar3D v3 SDK 3.3.5.17625\Utilities\SimConnect SDK\Inc
6. expand linker
7. include new lib folder - in my case F:\Program Files (x86)\Lockheed Martin\Prepar3D v3 SDK 3.3.5.17625\Utilities\SimConnect SDK\lib
8. select command line in Linker
9. in textbox type simconnect.lib (see SDK documentation)
10. build solution

You may also need to change the platform to V120 2013 in Configuration properties - General
and x86 only
Ron
bovril
Posts: 8
Joined: Thu Apr 05, 2012 7:26 pm

Re: visual studio 2015 & latest std

Post by bovril »

still no joy :(

Warning 1 warning C4627: '#include <windows.h>': skipped when looking for precompiled header use c:\users\bovril\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 11 1 ConsoleApplication1
Warning 2 warning C4627: '#include "SimConnect.h"': skipped when looking for precompiled header use c:\users\bovril\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 14 1 ConsoleApplication1
Warning 3 warning C4627: '#include <strsafe.h>': skipped when looking for precompiled header use c:\users\bovril\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 15 1 ConsoleApplication1
Error 4 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? c:\users\bovril\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 139 1 ConsoleApplication1
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: visual studio 2015 & latest std

Post by ronh991 »

Did you create an empty project? Seems you have extra crap with pre compiled headers
Ron
bovril
Posts: 8
Joined: Thu Apr 05, 2012 7:26 pm

Re: visual studio 2015 & latest std

Post by bovril »

tried blank project still get cant open file simconnect.dll

is this another of these poorly supported products that are released with little testing/documentation?

does anyone have a simple example that I can compile under VS 2015 just to test?
kmelsha
Posts: 1
Joined: Sun Aug 28, 2016 11:50 pm

Re: visual studio 2015 & latest std

Post by kmelsha »

Your problems have nothing to do with the sample code. You seem to be learning VS at the same time you're learning the SDK. I don't see that you included stdafx.h. Instant pre-compiled include errors right there. As for the documentation, it isn't that bad. It does assume you've been programming for a while. Have you installed simconnect? Can't find the DLL without that.
bertlaverman
Posts: 16
Joined: Fri Aug 07, 2015 9:10 am

Re: visual studio 2015 & latest std

Post by bertlaverman »

Agree with the previous. You made a project with pre-compiled headers turned on, so you must start all

Code: Select all

.CPP
files a line stating

Code: Select all

#include "stdafx.h"
. When you add a new item to such a project and select C++ source file as file type, the editor will even (should) put this line in there in grey. If you start typing in front of that line and this line ends up as last, you're in trouble. Don't worry if stdafx.h is empty, the compiler specifically looks for a header file with that name.

Cheers,
Bert Laverman
Bert Laverman
bovril
Posts: 8
Joined: Thu Apr 05, 2012 7:26 pm

Re: visual studio 2015 & latest std

Post by bovril »

Ive managed to get the example working with VS 2013..

I have got the data from the sim I required.

is it possible just to send the sim data? I have seen example where a key on the keyboards is mapped to an event and data updated.. can an external program just tell the sim to for example retract undercarriage?
zeidan
Posts: 13
Joined: Sat Jan 17, 2015 12:38 pm

Re: visual studio 2015 & latest std

Post by zeidan »

ronh991 wrote:Here are the steps I do:

1. create project (P3DTest) - Win32 console app - empty project
2. Copy paste the code example to a new cpp file (P3Dtest.cpp)
3. Right click on the project select properties.
4. expand C++
5. add new inc folder - in my case its F:\Program Files (x86)\Lockheed Martin\Prepar3D v3 SDK 3.3.5.17625\Utilities\SimConnect SDK\Inc
6. expand linker
7. include new lib folder - in my case F:\Program Files (x86)\Lockheed Martin\Prepar3D v3 SDK 3.3.5.17625\Utilities\SimConnect SDK\lib
8. select command line in Linker
9. in textbox type simconnect.lib (see SDK documentation)
10. build solution

You may also need to change the platform to V120 2013 in Configuration properties - General
and x86 only
Hi, ronh991,

I´m using VS 2015 Community and having the same issue of this post and faced another situation:

I´ve followed all your steps. Clicked Build and the VS output says "succeeded", but no exe file is created. It created a file named P3DTest.log with nothing inside of it.

My P3d V2.5 is installed in a different drive other than Windows and SDK stuff in the default path. Because of this, I run ConfigSDK.exe to reconfigurate all the environment.

Any suggestions?
Locked