Jump to content
  • Advertisement
Sign in to follow this  
XoreDevelopment

Linking in VS 2005

This topic is 4515 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm getting a few Linking Errors with my code. Here are the linking errors (And some odd warning about strcpy being deprecated)
Quote:
Compiling... D3DGUI.cpp .\D3DGUI.cpp(19) : warning C4996: 'strcpy' was declared deprecated C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy' Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.' Linking... SourceCore.obj : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance D3DGUI.obj : error LNK2001: unresolved external symbol "class CDisplayBox * g_pConsoleDisplay" (?g_pConsoleDisplay@@3PAVCDisplayBox@@A) D3DGUI.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CDisplayBox::Render(class CForm *,unsigned char)" (?Render@CDisplayBox@@UAEXPAVCForm@@E@Z) D3DGUI.obj : error LNK2001: unresolved external symbol "public: static class CDisplayBox * __cdecl CDisplayBox::Create(int,int,int,int,int)" (?Create@CDisplayBox@@SAPAV1@HHHHH@Z) D3DGUI.obj : error LNK2001: unresolved external symbol "public: virtual class CFormObject * __thiscall CForm::AddControl(class CFormObject *)" (?AddControl@CForm@@UAEPAVCFormObject@@PAV2@@Z) D3DGUI.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CForm::InputCharacter(char)" (?InputCharacter@CForm@@UAEXD@Z) D3DGUI.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CForm::MouseClick(int,int,bool)" (?MouseClick@CForm@@UAEXHH_N@Z) D3DGUI.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CForm::Move(int,int)" (?Move@CForm@@UAEXHH@Z) D3DGUI.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CForm::Render(unsigned char)" (?Render@CForm@@UAEXE@Z) D3DGUI.obj : error LNK2001: unresolved external symbol "public: virtual bool const __thiscall CForm::IsSelected(class CFormObject *)const " (?IsSelected@CForm@@UBE?B_NPAVCFormObject@@@Z) D3DGUI.obj : error LNK2001: unresolved external symbol "public: virtual struct rect_s const & __thiscall CForm::GetRect(void)const " (?GetRect@CForm@@UBEABUrect_s@@XZ) D3DGUI.obj : error LNK2001: unresolved external symbol "public: static class CEditBox * __cdecl CEditBox::Create(char *,int,int,int,int,int,bool)" (?Create@CEditBox@@SAPAV1@PADHHHHH_N@Z)
I'm sure someone here knows how to handle this. I would appreciate it very much :)

Share this post


Link to post
Share on other sites
Advertisement
I am not too sure about the "strcpy" deprecation issue. But the other linker errors are telling you that those functions cannot be found. Make sure you're linking properly to whatever it is you are using.

Share this post


Link to post
Share on other sites
The deprecation warning is new in VC++8, it is intended to warn the programmer that strcpy is potentially unsafe (can cause buffer overflows).


As for the linker warnings, that can be caused by a few things.

1. You are not linking to a required library. If you wrote all of the code, then this probably does not concern you.

2. The appropriate cpp files are not part of your MSVC project.

3. The implementations of the functions do not match their definitions, i.e.:
void DoSomething();

void DoSomething( int i ) {
// code;
}
4. There are more cases, but the ones I can think of don't seem to apply.


[edit] (Off-Topic) Are you trying to use C++/CLI?



jfl.

Share this post


Link to post
Share on other sites
OK, I took care of the warnings. And here is the source (.cpp) I'm trying to use, I'll put the header in here too.

#include "d3d9.h"
#include <d3dx9core.h>
#include "NormGUI.h"
#include "d3d9dev.h"
#include "d3d9int.h"
#include "d3d9tex.h"

#pragma comment(lib,"d3d9.lib")
#pragma comment(lib,"d3dx9.lib")



//CGui Gui;
//CDisplayBox ConsoleDisplay;
GENERATE_FORM(CConsoleForm);

CD3DRender *g_pRender;// = new CD3DRender(128);
CD3DFont *g_pD3Dfont = new CD3DFont("Arial", 16, FT_NONE);

void CConsoleForm::Initialize()
{
strcpy_s(m_szTitle, "Console");
m_Rect.x = 30;
m_Rect.y = 30;
m_Rect.width = 480;
m_Rect.height = 250;

//AddControl(CEditBox::Create("Default Text",2,m_Rect.height-18,m_Rect.width-4,16,16,true));
//AddControl( CEditBox::Create("Default Text", 2, m_Rect.height-18, m_Rect.width-4, 16, 16, &ParseCmd, true) );
//CDisplayBox = (CDisplayBox*)AddControl( CDisplayBox::Create(2, 2, m_Rect.width-4, m_Rect.height-20, 16) );

m_Rect.height += (int)TITLEBAR_HEIGHT;

}

void PrintText(float X,float Y, DWORD Color,char *szText)
{

}

void CGui::Initialize()
{
m_vFormList.push_back(new CConsoleForm);

m_topWindow = (int)m_vFormList.size() - 1;
for(int i=0; i <= m_topWindow; i++)
m_vFormList->Initialize();
}

void CGui::HandleInput(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
HandleKeyboard(wParam);
break;

case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK:
LeftButton(false);
break;

case WM_LBUTTONUP:
LeftButton(true);
break;

case WM_MOUSEMOVE:
MouseMove();
break;

default:
break;
}
}

void CGui::HandleKeyboard(WPARAM wParam)
{
bool bShiftDown = ((GetKeyState(VK_SHIFT)&0xFF00) != 0); //is down
char keyToSend = 0;

if(wParam >= 'A' && wParam <= 'Z')
{
keyToSend = (bShiftDown ? (char)(wParam&0xFF) : (char)(wParam&0xFF)+32);
}
else if(wParam >= '0' && wParam <= '9')
{
switch(wParam)
{
case '0':
keyToSend = (bShiftDown ? ')' : (char)(wParam&0xFF)); break;
case '1':
keyToSend = (bShiftDown ? '!' : (char)(wParam&0xFF)); break;
case '2':
keyToSend = (bShiftDown ? '@' : (char)(wParam&0xFF)); break;
case '3':
keyToSend = (bShiftDown ? '#' : (char)(wParam&0xFF)); break;
case '4':
keyToSend = (bShiftDown ? '$' : (char)(wParam&0xFF)); break;
case '5':
keyToSend = (bShiftDown ? '%' : (char)(wParam&0xFF)); break;
case '6':
keyToSend = (bShiftDown ? '^' : (char)(wParam&0xFF)); break;
case '7':
keyToSend = (bShiftDown ? '&' : (char)(wParam&0xFF)); break;
case '8':
keyToSend = (bShiftDown ? '*' : (char)(wParam&0xFF)); break;
case '9':
keyToSend = (bShiftDown ? '(' : (char)(wParam&0xFF)); break;
default:
break;
}
}
else
{
switch(wParam)
{
case VK_RETURN:
keyToSend = VK_RETURN; break;
case VK_BACK:
keyToSend = VK_BACK; break;
case VK_SPACE:
keyToSend = ' '; break;
default:
break;
}
}

//if(keyToSend != 0)
//m_vFormList[m_topWindow]->InputCharacter(keyToSend);
}

void CGui::MouseMove()
{
if(m_isDrag)
{
m_vFormList[m_topWindow]->Move(m_mouseX-m_mouseClickPt[0], m_mouseY-m_mouseClickPt[1]);
m_mouseClickPt[0] = m_mouseX;
m_mouseClickPt[1] = m_mouseY;
}
}

void CGui::LeftButton(bool bUp)
{
if(bUp)
m_isDrag = false;
else
{
rect_s pos;
int x, y, width, height;

for(int i=m_topWindow; i >= 0; i--)
{
pos = m_vFormList->GetRect();
x = pos.x;
y = pos.y;
width = pos.width;
height = pos.height;

if((m_mouseX > x) && (m_mouseX < x+width) && (m_mouseY > y) && (m_mouseY < y+height))
{
CForm *pTempForm = m_vFormList;//move the
m_vFormList.erase( m_vFormList.begin() + i ); //current window to
m_vFormList.push_back(pTempForm); //the top

if(m_mouseY < y+TITLEBAR_HEIGHT)
{
m_isDrag = true;
m_mouseClickPt[0] = m_mouseX;
m_mouseClickPt[1] = m_mouseY;
}
else
{
m_vFormList->MouseClick(m_mouseX, m_mouseY);
}
break;
}
}
}
}

void CGui::SetMousePos(int x, int y)
{
m_mouseX = x;
m_mouseY = y;
}

void CGui::GetMousePos(int &x, int &y)
{
x = m_mouseX;
y = m_mouseY;
}

void CGui::RenderAll()
{
for(int i=0; i <= m_topWindow; i++)
{
BYTE alpha = ( i == m_topWindow ? 0xBF : 0x3F );
m_vFormList->Render(alpha);
}

RenderCursor();
}

void CGui::RenderCursor()
{
FillRGBA(m_mouseX-1.0f,m_mouseY-10.0f,2.0f,20.f,187,76,30,230);
FillRGBA(m_mouseX-10.0f,m_mouseY-1.0f,20.f,2.0f,187,76,30,230);
}

void CGui::InitDisplay()
{
IDirect3DDevice9 *m_pD3Ddev;
//CD3DRender *g_pRender = new CD3DRender(128);
g_pRender->Initialize(m_pD3Ddev);
g_pD3Dfont->Print(0,0,0xFF00FF00,"Hello",FT_NONE);
//g_pD3Dfont->GenFont(m_pD3Ddev, "Arial Black", 10, 0x0);
}

void CGui::CleanupDisplay()
{
g_pRender->Invalidate();
g_pD3Dfont->Invalidate();
}


And here is the header for this:

#include <vector>
#include <d3d9.h>
#include "d3drender.h"
#include "d3d9dev.h"

#ifndef RECT_STRUCT
#define RECT_STRUCT
struct rect_s { int x, y, width, height; };
#endif

#define FOTYPE_EDITBOX 0x00000001
#define FOTYPE_BUTTON 0x00000002
#define FOTYPE_DISPLAYBOX 0x00000004

class CForm;

#ifndef RECT_STRUCT
#define RECT_STRUCT
struct rect_s { int x, y, width, height; };
#endif

typedef void (*tpFunc)();
typedef void (*tpFuncChar)(char*);

#define _CBUTTON(p) ((CButton*)(p))
#define _CEDITBOX(p) ((CEditBox*)(p))
#define _CDISPLAYBOX(p) ((CDisplayBox*)(p))

#define FOTYPE_EDITBOX 0x00000001
#define FOTYPE_BUTTON 0x00000002
#define FOTYPE_DISPLAYBOX 0x00000004

class CFormObject
{
public:
CFormObject(){ m_szText = NULL; m_enabled = true; m_type = 0; }
~CFormObject(){ if(m_szText) delete [] m_szText; }

virtual void Render(CForm *pForm, BYTE alpha) = 0;

virtual const rect_s &GetRect() const { return m_Rect; }
virtual DWORD GetType() { return m_type; }
virtual void SetEnabled(bool enabled) { m_enabled = enabled; }
virtual bool GetEnabled() const { return m_enabled; }

protected:
rect_s m_Rect;
DWORD m_type;
char *m_szText;
bool m_enabled;
};

/* CButton */
class CButton : public CFormObject
{
public:
CButton() { m_type = FOTYPE_BUTTON; }

//general methods
static CButton *Create(char *szText, int x, int y, int width, int height, tpFunc pFunc);
void Initialize(char *szText, int x, int y, int width, int height, tpFunc pFunc);
void Render(CForm *pForm, BYTE alpha);

//specific methods
void Click() { if(m_pFunc != NULL) m_pFunc(); }

private:
tpFunc m_pFunc;
};

/* CEditBox */
class CEditBox : public CFormObject
{
public:
CEditBox() { m_type = FOTYPE_EDITBOX; }

//general methods
static CEditBox *Create(char *szDefaultText, int x, int y, int width, int height, int maxChar/*, tpFuncChar pFuncChar*/,bool bClear=false);
void Initialize(char *szDefaultText, int x, int y, int width, int height, int maxChar, /*tpFuncChar pFuncChar,*/ bool bClear=false);
void Render(CForm *pForm, BYTE alpha);

//specific methods
void OnReturn();
void SetText(char *szText);
void AddChar(char c);
void RemChar();
void ClearText();

private:
tpFuncChar m_pFuncChar;
int m_maxChar; //doesn't count '\0'
int m_usedChar;
bool m_clearOnRet;
};

/* CDisplayBox */
class CDisplayBox : public CFormObject
{
public:
CDisplayBox() { m_type = FOTYPE_DISPLAYBOX; }

//general methods
static CDisplayBox *Create(int x, int y, int width, int height, int maxLines);
void Initialize(int x, int y, int width, int height, int maxLines);
void Render(CForm *pForm, BYTE alpha);

//specific methods
void AddText(char *szText);
void Clear();

protected:
std::vector<char*> m_vText;
int m_maxLines;
};


void FillRGBA(float x, float y, float w, float h, int r, int g, int b, int a)
{
D3DXVECTOR2 vLine[2];
ID3DXLine *pLine;

pLine->SetWidth( w );
pLine->SetAntialias( false );
pLine->SetGLLines( true );

vLine[0].x = x + w/2;
vLine[0].y = y;
vLine[1].x = x + w/2;
vLine[1].y = y + h;

pLine->Begin( );
pLine->Draw( vLine, 2, D3DCOLOR_RGBA( r, g, b, a ) );
pLine->End( );
}


/*class CGui
{
public:
bool m1pressed;
bool m2pressed;
int mainmenubuttons; // Number of buttons to be drawn in the MAIN menu.

void drawGui(char* text);
void drawMouse(int x, int y);
void setValues();
void setCvars();

private:

void drawTitlebar(char* text);
void drawBox(int x, int y,int w, int optioncount);
void drawButton(int x, int y,int r, int g, int b, char* text);
void drawButton2(int x, int y,int r, int g, int b, char* text);
void drawSlideBar(int x, int y, int r, int g, int b, int cvar, int maxvalue);
void drawSubMenu(int x, int ax);

int checkField(int x, int y, int w, int h);
void checkMenu(int x, char* text, int mouseclick);
void setSubMenu(int x, int ax, int bx);
void set_menu_bool(int ax);
};*/



struct menu_s
{
char* text;
int value;
bool menuopen; //only used for menu[?][0]
};

//============================================
//============================================
//============================================
#ifndef _GUI_FORM_H
#define _GUI_FORM_H

#define GENERATE_FORM(f) class f : public CForm { void Initialize(); }

#ifndef RECT_STRUCT
#define RECT_STRUCT
struct rect_s { int x, y, width, height; };
#endif

#define TITLEBAR_LENGTH 32
#define TITLEBAR_HEIGHT 16.0f
#define WINDOW_COLOUR 0x00CCCCCC
#define TITLEBAR_COLOUR 0x00336699
#define BORDER_3D_DOWN 0x3F000000
#define BORDER_3D_UP 0x3FFFFFFF
#define TEXT_COLOUR 0x00003366
#define TITLEBAR_TEXT_COLOUR 0x00CFCFDF


/* CForm */
class CForm
{
public:
CForm(){}
~CForm(){}

//pure methods
virtual void Initialize() = 0;

//accessors
virtual const rect_s &GetRect() const;
virtual const bool IsSelected(CFormObject *pObject) const;

//methods
virtual void Render(BYTE alpha);
virtual void Move(int offsetx, int offsety);
virtual void MouseClick(int mousex, int mousey, bool isDoubleClick = false);
virtual void InputCharacter(char c);
virtual CFormObject *AddControl(CFormObject *pObject);

protected:
std::vector<CFormObject*> m_vObjectList;

rect_s m_Rect;
char m_szTitle[TITLEBAR_LENGTH+1];
CFormObject *m_pSelected;
};


#endif



//============================================
//============================================
//============================================
#ifndef _GUI_H
#define _GUI_H

//rendering (used by all classes)
void FillGradient(float x, float y, float width, float height, DWORD col1, DWORD col2);
void PrintText(float X, float Y, DWORD Color, char *szText);

class CGui
{
public:
CGui()
{
//ID3DXFont *g_pFont;
CD3DRender *g_pRender = new CD3DRender(128);
CD3DFont *g_pD3Dfont = new CD3DFont("Arial", 16, false);
m_topWindow = -1;
}
~CGui(){}

bool m1pressed;
bool m2pressed;
int mainmenubuttons; // Number of buttons to be drawn in the MAIN menu.

void drawGui(char* text);
void drawMouse(float x, float y);
void setValues();
void setCvars();

void Initialize();
void InitDisplay();
void CleanupDisplay();

void RenderAll();
void RenderCursor();

void HandleInput(UINT message, WPARAM wParam, LPARAM lParam);
void HandleKeyboard(WPARAM wParam);
void MouseMove();
void LeftButton(bool bUp = false);

void SetMousePos(int x, int y);
void GetMousePos(int &x, int &y);

private:
std::vector<CForm*> m_vFormList;

void drawTitlebar();
void drawBox(float x, float y,float w, int optioncount);
void drawButton(float x, float y,int r, int g, int b, char* text);
void drawButton2(float x, float y,int r, int g, int b, char* text);
void drawSlideBar(float x, float y, int r, int g, int b, int cvar, int maxvalue);
void drawSubMenu(float x, int ax);

int checkField(float x, float y, int w, int h);
void checkMenu(float x, char* text, int mouseclick);
void setSubMenu(float x, int ax, int bx);
void set_menu_bool(int ax);


int m_topWindow;
bool m_isDrag;
int m_mouseClickPt[2];
int m_mouseX, m_mouseY;
};

/*extern CGui g_GUI;
extern CDisplayBox *g_pConsoleDisplay;*/


#endif


Sorry if that took alot of space!!

Share this post


Link to post
Share on other sites
Quote:
Original post by XoreDevelopment
Sorry if that took alot of space!!


hehe - next time use [ source ] [ /source ] tags. Like this:

blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
AMAZING - it scrolls!
blah
blah

Share this post


Link to post
Share on other sites
In the code you posted, I never actually see you implement the virtual methods of CForm. Do you want them to be pure virtual? If so, then you cannot instantiate CConsoleForm without implementing all the pure virtual functions. Otherwise, you need to implement them in CForm.

Also, FillRGBA should not be implemented in the header file, or you are going to get redefinition errors.

I can't tell about the rest since we're missing some code.

Share this post


Link to post
Share on other sites
Quote:
Original post by jflanglois
In the code you posted, I never actually see you implement the virtual methods of CForm. Do you want them to be pure virtual? If so, then you cannot instantiate CConsoleForm without implementing all the pure virtual functions. Otherwise, you need to implement them in CForm.

Also, FillRGBA should not be implemented in the header file, or you are going to get redefinition errors.

I can't tell about the rest since we're missing some code.


Do you have a messenger or something of the sort so I can give you my source to look at?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!