• 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.

Errors with a new c++ project.

Messages
9
Country
ca-quebec
Hello everyone,

It has been more than a week that I am trying to create a simple project using C++ without any success.

I use Visual Studio 2015, I tried to create a Win32 project and a C++ universal application but both are giving me errors when I try to build. I am actually on the C++ win32 project, I've added the path to both the PMDG_NGX_SDK.h and SimConnect.h, I also added the path to the SimConnect.lib file, I've added it also in Linker > Command line. I'm using this simple test code :

PHP:
#include <windows.h>

#include "SimConnect.h"
#include "PMDG_NGX_SDK.h"

HANDLE  hSimConnect = NULL;

void ChangeVehicle()
{
    HRESULT hr;

    if (SUCCEEDED(SimConnect_Open(&hSimConnect, "Change Vehicle", NULL, 0, 0, 0)))
    {
        // Sending the title of the vehicle
        SimConnect_ChangeVehicle(hSimConnect, "Maule M7 260C paint2");

        hr = SimConnect_Close(hSimConnect);
    }
}

void main() {
    ChangeVehicle();

}

But I get these errors :

Code:
Error    LNK2019    unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)    CockpitControl-win32    CockpitControl-win32\MSVCRTD.lib(exe_winmain.obj)    1
Error    LNK2019    unresolved external symbol __imp__printf referenced in function "public: virtual void __thiscall CClient::Reset(void)" (?Reset@CClient@@UAEXXZ)    CockpitControl-win32    CockpitControl-win32\SimConnect.lib(client.obj)    1
Error    LNK2019    unresolved external symbol __imp___vsnprintf referenced in function "long __cdecl StringCbPrintfA(char *,unsigned int,char const *,...)" (?StringCbPrintfA@@YAJPADIPBDZZ)    CockpitControl-win32    CockpitControl-win32\SimConnect.lib(commClient.obj)    1
Error    LNK2019    unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::_System_error_category::message(int)const " (?message@_System_error_category@std@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@H@Z)    CockpitControl-win32    CockpitControl-win32\SimConnect.lib(SimConnectClient.obj)    1

What I am trying to do is just to create a simple application that can have a UI (that's why I tried the universal application) but days have passed and so far I got only erros.

Thanks for your help.
 
What version of SimConnect.lib are you linking?
I use the sdk of P3D v3, I can't find the version of that file.

I guess your app entry point is specified as WinMain() rather than main(), so either replace main() with WinMain() or change entry point in the linker options

for other errors I would google around, for example: http://stackoverflow.com/questions/...rnal-symbol-imp-fprintf-and-imp-iob-func-sdl2

none of your errors looks like FSX/P3D related....

M.

I changed the entry point to main and then winmain() and even MainPage() for the universal application, none of them resolved the problems.

I've looked at the link you provided but didn't manage to get a solution.

Thanks for your help.
 
SimConnect for v3 is compiled with VS2013. I believe there's a way to tell VS2015 to use the 2013 libraries.
 
I've created the same project with Visual Studio 2013, and the same problem. Just to be sure that I follow the right procedure when I create a new project :

1. I add the additional include directories, they are 2, one contains SimConnect.h and the other one contains PMDG_NGX_SDK.h

2. I add the additional library directories, only one and it contains the SimConnect.lib file.

3. I add SimConnect.lib in the additional options of Linker > Command Line

Maybe I forgot something that's why it doesn't work?
 
I would suggest trying just an SDK example in VS2013 - then move it to VS2015 (please note you may have to change the platform from v190 to v180) and see what happens. I am in the process of doing this also, because VS2015 seems to have changed a lot of legacy stuff too.

Edit v120 and v140
 
Last edited:
I would suggest trying just an SDK example in VS2013 - then move it to VS2015 (please note you may have to change the platform from v190 to v180) and see what happens. I am in the process of doing this also, because VS2015 seems to have changed a lot of legacy stuff too.

Edit v120 and v140

I just opened a project sample on Visual Studio 2013, and without any modification I click on Build, I get this error :

Code:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgrade Solution...".

There is no Upgrade Solution option, and I can't find a link to download the v140 tools.
 
You must have inadvertently changed the sln file when you opened it in VS2015. V140 is for VS2015, Try to change the platform back to v120 in the dropdown. Or open another sln file in vs2013 that has not been changed.

All I do is:

Create a new project - any name
Create a console win32 app empty project
add the inc file locations for v3
add the lib locations for v3
add simconnect.lib to linker command line section
copy the cpp code from an existing sample - code only using copy paste.
build

I did the above with VS2013 and then VS2015. Only difference was I change the platform in VS2015 to v120 from v140. Works for me.
 
Hi, thanks for your answer, but it still don't work.

At this point I really don't know what I am doing wrong! I have both VS2015 and VS2013, I followed exactly the same steps you mentionned and I still get errors :

Code:
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Mehdi\Desktop\ConsoleApplication1\Debug\ConsoleApplication1.exe : fatal error LNK1120: 1 unresolved externals

In VS2015 I don't have the v120 in the plateform toolset.

Is there a sample project that I can download somewhere?

Thanks.
 
Hi, thanks for your answer, but it still don't work.

At this point I really don't know what I am doing wrong! I have both VS2015 and VS2013, I followed exactly the same steps you mentionned and I still get errors :

Code:
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Mehdi\Desktop\ConsoleApplication1\Debug\ConsoleApplication1.exe : fatal error LNK1120: 1 unresolved externals

In VS2015 I don't have the v120 in the plateform toolset.

Is there a sample project that I can download somewhere?

Thanks.

Then your install is messed up. The only way to have v120 is to install VS2013, you say you did. Are you looking in the General Tab of the Project Properties.

MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

This seems to be related to a making the project a console app, not win32.

I can't upload an example as VS2015 has this huge sdf file in the project and it's too big for FSDeveloper. A 2M file has a 45M sdf in it (used for intelisense - can't delete)
 
Last edited:
Hi,

For unknown reason I can see now the v120 on VS2015. I resolved some problems and others still exists.

I was using int main() in the win32 application that's why it keeps giving me the errors, now I use this code :

PHP:
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>

#include "PMDG_NGX_SDK.h"
#include "SimConnect.h"

HANDLE  hSimConnect = NULL;

void ChangeVehicle()
{
    HRESULT hr;

    if (SUCCEEDED(SimConnect_Open(&hSimConnect, "Change Vehicle", NULL, 0, 0, 0)))
    {
        // Sending the title of the vehicle
        SimConnect_ChangeVehicle(hSimConnect, "Maule M7 260C paint2");

        hr = SimConnect_Close(hSimConnect);
    }
}

INT WINAPI wWinMain(HINSTANCE hInst,
    HINSTANCE hPrevInst,
    LPWSTR lpCmdLine,
    INT nShowCmd)

{
    // My Code HERE
    ChangeVehicle();

    return 0;
}

But I still have 3 errors :

1>SimConnect.lib(client.obj) : warning LNK4099: PDB 'sim.pdb' was not found with 'SimConnect.lib(client.obj)'
1>SimConnect.lib(commClient.obj) : warning LNK4099: PDB 'sim.pdb' was not found with 'SimConnect.lib(commClient.obj)'
1>SimConnect.lib(SimConnectClient.obj) : warning LNK4099: PDB 'sim.pdb' was not found with 'SimConnect.lib(SimConnectClient.obj)'

Any idea for where it may come from?
 
OK I was doing a console app. Let me catch up to you and try a win app (A GUI instead of a console - that's what you are trying correct?)

Did you create an empty project or something specific ATL or MFC etc.

I used
Code:
int __cdecl _tmain(int argc, _TCHAR* argv[])
{
    testAIAircraft();
    return 0;
}
 
I did both of them none worked, but yes I'm doing now a Win32 Project, and in the Win32 Application Wizard I choose Windows Application and Empty project. All I'm creating is a single cpp file containing the code I wrote.
 
I was able to compile your code.

Create a win32 app.
Empty project.
Set Inc folder
Set Lib Folder
add simconnect.lib to Linke command line section
Set the General Tab - Toolset to v120
Set the Linker General Tab - Ignore Import Library - Yes (this gets rid of your last few errors) warnings remain.

Compile and run with P3D - sets aircraft to Maule then causes crash.

This link has the code solution in a zip.

Edit:

only worked in debug - release version does not.
simconnect.lib(SimConnectClient.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)"
 
Last edited:
Ok, now that you have that going, I suggest to attack your project in a slightly different manner. Create a win32 application that is not an empty project. (does not need to be MFC or ATL yet). You can do all the win32 GUI stuff and you can also make the console application samples GUI applications with a multiline text box as the output area. You need to read up on threads. Basically the testxxx function is the background thread and the call back is still the call back for simconnect.

Your program will have two callbacks - one for all the windows events and one for the Simconnect events. There are some thread here that have examples, it's how I got started in understanding this.
 
Back
Top