Error Having troubble building my c++ project

Alexw95

Addon Developer
Addon Developer
Joined
May 28, 2010
Messages
262
Reaction score
0
Points
16
Location
Vancouver BC
hi i am trying to build my first mfd so i can see if it works it is not done yet but i want to see what it looks like at this stage in orbiter. i am using visual studio 2010 pro i and made the project a win32 dll with a precompiled header.

when i went to build my project i got thesse errors

Code:
Error    16    error LNK1120: 15 unresolved externals    C:\Users\Alex\Desktop\VSAS\Release\VSAS.dll    VSAS
Error    5    error LNK2001: unresolved external symbol "__declspec(dllimport) bool __cdecl oapiUnregisterMFDMode(int)" (__imp_?oapiUnregisterMFDMode@@YA_NH@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    4    error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl oapiRegisterMFDMode(struct MFDMODESPEC &)" (__imp_?oapiRegisterMFDMode@@YAHAAUMFDMODESPEC@@@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    2    error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall MFD::MFD(unsigned long,unsigned long,class VESSEL *)" (__imp_??0MFD@@QAE@KKPAVVESSEL@@@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    3    error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall MFD::~MFD(void)" (__imp_??1MFD@@UAE@XZ)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    12    error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual bool __thiscall MFD::ConsumeKeyImmediate(char *)" (__imp_?ConsumeKeyImmediate@MFD@@UAE_NPAD@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    10    error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall MFD::ReadStatus(void *)" (__imp_?ReadStatus@MFD@@UAEXPAX@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    8    error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall MFD::RecallStatus(void)" (__imp_?RecallStatus@MFD@@UAEXXZ)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    9    error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall MFD::StoreStatus(void)const " (__imp_?StoreStatus@MFD@@UBEXXZ)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    11    error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall MFD::WriteStatus(void *)const " (__imp_?WriteStatus@MFD@@UBEXPAX@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    7    error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall MFD::Title(struct HDC__ *,char const *)const " (__imp_?Title@MFD@@QBEXPAUHDC__@@PBD@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    6    error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl oapiOpenInputBox(char *,bool (__cdecl*)(void *,char *,void *),char *,int,void *)" (__imp_?oapiOpenInputBox@@YAXPADP6A_NPAX01@Z0H1@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    15    error LNK2001: unresolved external symbol "bool __cdecl CrewSize(void *,char *,void *)" (?CrewSize@@YA_NPAXPAD0@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    14    error LNK2001: unresolved external symbol "bool __cdecl PilotID(void *,char *,void *)" (?PilotID@@YA_NPAXPAD0@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    13    error LNK2001: unresolved external symbol "bool __cdecl VessleID(void *,char *,void *)" (?VessleID@@YA_NPAXPAD0@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    1    error LNK2001: unresolved external symbol "void __cdecl dummy(void)" (?dummy@@YAXXZ)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS

can some one please help me thanks
 
What have you tried in order to fix the mutliple errors? Do you know why you are seeing them and what an 'unresolved external symbol' is?
 
my coding is very poor at the moment as i basicly only leared c++ 2 days ago i thought i would give a try making a simple mfd based off of orbiter sdk's custom mfd and i have no idea what those errors are could you help me out please :embarrassed:
 
You did include the Orbiter SDK files didn't you? I'm pretty sure you can get these errors when you don't
 
You did include the Orbiter SDK files didn't you? I'm pretty sure you can get these errors when you don't
yes i did as earlyer i used orbiter wiki to help me set up my visual studio
 
Ok, Mind showing us your code?
 
sure but dont laugh

Code:
// VSA.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"

#include "VSAS.h"

#define STRICT
#define ORBITER_MODULE
#include <Orbitersdk.h>
#include "VSAClient.h"
#include <stdio.h>
#include <windows.h>
#include <math.h>
static int mode;


// GLOBAL VARS

const int ndata = 200;  // data points
const double sample_dt = 5.0; // data point interval

static struct {  // "VSA Client" parameters
    int mode;      // identifier for new MFD mode
} g_VSAClient;

static struct {  // global data storage
    double tnext;  // time of next sample
    int   sample;  // current sample index
    float* time;   // sample time
    float* lox;  // LOX data
    float* fuel;   // Fuel velocity data
      
} g_Data;

///////////////////////////////////////////////////////////////
// API interface
DLLCLBK void opcDLLInit (HINSTANCE hDLL) 
{
    static char *name = "VSA Client";   // TODO: MFD mode name
    MFDMODESPEC spec;
    spec.name = name;
    spec.key = OAPI_KEY_V;                // TODO: MFD mode selection key
    spec.msgproc = VSAClient::MsgProc;  // MFD mode callback function

    // Register the new MFD mode with Orbiter
    
    
    g_Data.time   = new float[ndata];   memset (g_Data.time,  0, ndata*sizeof(float));
    g_Data.lox    = new float[ndata];   memset (g_Data.lox,   0, ndata*sizeof(float));
    g_Data.fuel   = new float[ndata];   memset (g_Data.fuel,  0, ndata*sizeof(float));
    
    g_VSAClient.mode = oapiRegisterMFDMode (spec);
}

DLLCLBK void ExitModule (HINSTANCE hDLL) 
{
    // Unregister the custom MFD mode when the module is unloaded
    oapiUnregisterMFDMode (g_VSAClient.mode);
    delete []g_Data.time;
    delete []g_Data.lox;
    delete []g_Data.fuel;
} 

DLLCLBK void opcPostStep (double SimT,double SimDT,double mjd) {



}

///////////////////////////////////////////////////////////////
// MFD class implementation
VSAClient::VSAClient (DWORD w, DWORD h, VESSEL *vessel)
: MFD (w, h, vessel) 
{


}

VSAClient::~VSAClient()
{
}

int VSAClient::MsgProc (UINT msg, UINT mfd, WPARAM wparam, LPARAM lparam)
// Standard message parser for messages passed from Orbiter
{
    switch (msg) 
    {
    case OAPI_MSG_MFD_OPENED:
        return (int) new VSAClient (LOWORD(wparam), HIWORD(wparam), (VESSEL*)lparam);
    }
    return 0;
}

int VSAClient::ButtonMenu (const MFDBUTTONMENU **menu) const
{
    static const MFDBUTTONMENU mnu[4] = 
    {
        {"Input Pilot ID", 0, 'P'},
        {"Input Vessle ID",0, 'S'},
        {"Input Crew Size",0, 'C'},
        {"Export",0, 'E'} 
    };
    if (menu) 
        *menu = mnu;
    return sizeof(4);
}

char* VSAClient::ButtonLabel(int bt)
{
    char *label[4] = {"PID","VID","CS","EX"};    // TODO: Put your button text here
    return (bt < 4  ? label[bt] : 0);
}

bool VSAClient::ConsumeKeyBuffered (DWORD key)
{
    bool PilotID (void *id, char *str, void *data);
    bool VessleID (void *id, char *str, void *data);
    bool CrewSize (void *id, char *str, void *data);
    
    switch (key) {
    case OAPI_KEY_P:
        oapiOpenInputBox ("Input Pilot ID Or Name: ", PilotID, 0, 20, (void*)this);
        return true;
        case OAPI_KEY_S:
        oapiOpenInputBox ("Input Vessle ID Or Name: ", VessleID, 0, 20, (void*)this);
        return true;
        case OAPI_KEY_C:
        oapiOpenInputBox ("Input Size Of Crew (eg: 2): ", CrewSize, 0, 20, (void*)this);
        return true;
    }
        return false; 
    
}

bool VSAClient::ConsumeButton(int bt, int event)
{
    if (!(event & PANEL_MOUSE_LBDOWN)) return false;
    static const DWORD btkey[4] = {OAPI_KEY_P, OAPI_KEY_S, OAPI_KEY_C};    // TODO: Put your key list in here
    if (bt < 4) return ConsumeKeyBuffered (btkey[bt]);
    else return false;
}

///////////////////////////////////////////////////////////////
//        General functions
void VSAClient::Update(HDC hDC)
{
    Title(hDC, "VSAClient");    // TODO: Put your title here
}

as you might see its useless to orbiter at this point all it will do is show buttons am i correct but i still would like to see were it is at at this point
 
You can't learn by having someone provide the answers. Have a few goes yourself then come back if you still have issues.

Also, try a few sites like this -> http://www.codeguru.com/forum/showthread.php?t=289136 <- They will help you understand what's going on.
:ditto:


Also, it seems to me you're creating a new thread for every little problem you have. Right after you stumble into something you don't know, follow this checklist:

  • Try to figure it out yourself. Come up with theories and test them extensively.
  • Check online FAQs, when applicable.
  • Use Google. It's impossible to stress this enough. Google the error message/issue exhaustively. 99.99% of the time, you'll find your answer.
  • Search your issue in specific places, such as specialized and related forums.
  • Make sure the previous items didn't yield any new information. If you discover anything new, go back to the top and do everything again.
  • Last resort: gather all information you have related to the problem(s), and write the best description of the issues you possibly can, including a descriptive title and proper grammar. Review it at least twice, then post in the appropriate place.
 
call me stupid but i still have no idea what is going on i manually loaded the orbiter sdk lib and include files into visual studio's program file that did not work i read the page u guys recomened me reading several times i do not get it..

if you dont mind helping me that would be greatly apreciated otherwise i can wait till my dad gets home and i can get him to help.

---------------------------
Orbiter forum has helped me with more things that i can think of :)
one day i will find a way to use what they showed me to help them in return
 
call me stupid but i still have no idea what is going on i manually loaded the orbiter sdk lib and include files into visual studio's program file that did not work i read the page u guys recomened me reading several times i do not get it..

You're in the right track, but adding the *.lib files to the project doesn't do anything but list them. To tell MSVC++ to use those libs, you'll have to go to project's properties (right click on the project->properties), go to linker->input (or something like that) and add both libs. You'll have to do this for both Debug and Release profiles.
 
Why do we now have 3 threads all about the same problem from the same user?
 
if you continue to have these problems (which i did too for a while), try doing RCLICK(on project)>>ADD>>EXISTING ITEM - then choose the needed libs "manually"....

that should fix it by pure "brute force":rolleyes:
 
ok im getting back on track now after telling VC++ to use those librarys now i only have 4 errors

Code:
Error    5    error LNK1120: 4 unresolved externals    C:\Users\Alex\Desktop\VSAS\Release\VSAS.dll    VSAS
Error    4    error LNK2001: unresolved external symbol "bool __cdecl CrewSize(void *,char *,void *)" (?CrewSize@@YA_NPAXPAD0@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    3    error LNK2001: unresolved external symbol "bool __cdecl PilotID(void *,char *,void *)" (?PilotID@@YA_NPAXPAD0@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    2    error LNK2001: unresolved external symbol "bool __cdecl VessleID(void *,char *,void *)" (?VessleID@@YA_NPAXPAD0@Z)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS
Error    1    error LNK2001: unresolved external symbol "void __cdecl dummy(void)" (?dummy@@YAXXZ)    C:\Users\Alex\Desktop\VSAS\VSAS\VSAClient.obj    VSAS

once again i really apreciate your help and i know i am a pain :P sorry about that

---------- Post added 06-30-10 at 12:00 AM ---------- Previous post was 06-29-10 at 11:13 PM ----------

by the looks of the error it is refering to this line in my source file

Code:
bool VSAClient::ConsumeKeyBuffered (DWORD key)
{
    bool PilotID (void *id, char *str, void *data);
    bool VessleID (void *id, char *str, void *data);
    bool CrewSize (void *id, char *str, void *data);
    
    switch (key) {
    case OAPI_KEY_P:
        oapiOpenInputBox ("Input Pilot ID Or Name: ", PilotID, 0, 20, (void*)this);
        return true;
        case OAPI_KEY_S:
        oapiOpenInputBox ("Input Vessle ID Or Name: ", VessleID, 0, 20, (void*)this);
        return true;
        case OAPI_KEY_C:
        oapiOpenInputBox ("Input Size Of Crew (eg: 2): ", CrewSize, 0, 20, (void*)this);
        return true;
    }
        return false; 
    
}

did i do somthign wrong?
 
You declared PilotID, VesselID and CrewSize but didn't implement them.
 
yes i got the problem fixed i didnt declair my fucntions thank you all
 
Back
Top