PDA

View Full Version : C++ unresolved external symbol



AjvBun
05-22-2016, 12:07 PM
Hello,
I am new in this world and new in C++ programming, I try to solve a simple problem, I hope. Can you assist me?
I wrote a minimal C++ program in VS2012 i.e.
=============
// vs-cpp : communicate with simconnect in FSX or Prepar3d

#include <Windows.h>
#include "SimConnect.h"

HANDLE hSim = NULL;

int tmain ()
{
HRESULT hr;

hr = SimConnect_Open (&hSim, "Test", NULL, 0, 0, SIMCONNECT_OPEN_CONFIGINDEX_LOCAL );
return 0;
}
================
It is compiling fine with Ctrl-F7
Building F7 - compiling and linking - gives the error
LNK2019: unresolved external symbol _SimConnect_Open@24 referenced in function "int __cdecl tmain(void)" (?tmain@@YAHXZ)
My Properties | Linker | Commandline is:

==================
/OUT:"E:\cpp\06_sim_open\Debug\hello.exe" /MANIFEST /NXCOMPAT /PDB:"E:\cpp\06_sim_open\Debug\hello.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /INCREMENTAL /PGD:"E:\cpp\06_sim_open\Debug\hello.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\hello.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\Program Files (x86)\Windows Kits\8.0\Include\um" /LIBPATH:"G:\Prepar3D v3 SDK 3.2.2.16659\Utilities\SimConnect SDK\lib" /TLBID:1
==================
which includes /LIBPATH:"G:\Prepar3D v3 SDK 3.2.2.16659\Utilities\SimConnect SDK\lib" and in that directory is SimConnect.lib

I have no idea where to look for a sulution, I searched this forum but was unable to find a hint.
Thanks in advance.

kiek
05-26-2016, 12:36 PM
Hallo,

1. Remove that /LIBPATH part.
2. Put a copy of SimConnect.lib in the same folder as your program.
3. Add SimConnect.lib in the Additional Options window (select Project properties->Linker->Command Line)

Groeten,
Nico