Strange linker error?

hellaeon

12-02-2009 14:06:34

I reckon you would have had this one before.

Continuing that last stuff I posted :)
I have loaded a sheet and am trying to add callbacks to the code like so


QuickGUI::Widget* w = NULL;
w = mGUIMgr->getActiveSheet()->findWidget("Host");
if(w != NULL)
w->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&MainGUI::HostServer,this);

// Connect
w = mGUIMgr->getActiveSheet()->findWidget("Connect");
if(w != NULL)
w->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&MainGUI::ConnectHost,this);

// Disconnect
w = mGUIMgr->getActiveSheet()->findWidget("Disconnect");
if(w != NULL)
w->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&MainGUI::DisconnectHost,this);

// Send a message
w = mGUIMgr->getActiveSheet()->findWidget("SendMessage");
if(w != NULL)
w->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&MainGUI::SendMessage,this);


However it generates a linker error :


1>MainGUI.obj : error LNK2001: unresolved external symbol "public: void __thiscall MainGUI::SendMessageW(class QuickGUI::EventArgs const &)" (?SendMessageW@MainGUI@@QAEXABVEventArgs@QuickGUI@@@Z)
1>MainGUI.obj : error LNK2001: unresolved external symbol "public: void __thiscall MainGUI::DisconnectHost(class QuickGUI::EventArgs const &)" (?DisconnectHost@MainGUI@@QAEXABVEventArgs@QuickGUI@@@Z)
1>MainGUI.obj : error LNK2001: unresolved external symbol "public: void __thiscall MainGUI::ConnectHost(class QuickGUI::EventArgs const &)" (?ConnectHost@MainGUI@@QAEXABVEventArgs@QuickGUI@@@Z)
1>MainGUI.obj : error LNK2001: unresolved external symbol "public: void __thiscall MainGUI::HostServer(class QuickGUI::EventArgs const &)" (?HostServer@MainGUI@@QAEXABVEventArgs@QuickGUI@@@Z)


Im not sure why, I thought maybe it was the visibility of the functions, but I have them private and tried both public and protected. In the PlayPen code, I see you have a similar set up - the MainForm (for me MainGUI) class loads the sheet and in the same function, runs the callback code - I still have NOT compiled your PlayPen code to see if that works but thats not going to be a compiling issue I dont think - im linking to the correct libraries as I can run it and load the sheet but it only starts crashing with the callback code....

Just in case here is my 'sheet'

Sheet DefaultSheet
{
BrushFilterMode BRUSHFILTER_LINEAR
ClipChildrenToDimensions true
ClipComponentsToDimensions true
ConsumeKeyboardEvents false
ContextMenuName
Dimensions 0 0 800 600
DisabledSkinType
Dragable false
Enabled true
HorizontalAnchor ANCHOR_HORIZONTAL_LEFT_RIGHT
HorzBarScrollPercent 0.2
HorzButtonScrollPercent 0.1
HoverTime 3
MaxSize 0 0
MinSize 0 0
PositionRelativeToParentClientDimensions true
Resizable false
ScrollBarThickness 15
Scrollable true
SkinType default
SupportScrolling false
TransparencyPicking true
VertBarScrollPercent 0.2
VertButtonScrollPercent 0.1
VerticalAnchor ANCHOR_VERTICAL_TOP_BOTTOM
Visible true
XScrollOffset 0
YScrollOffset 0

Child widgets
{
Button Host
{
AllottedWidth 96
BrushFilterMode BRUSHFILTER_LINEAR
ConsumeKeyboardEvents false
ContextMenuName
Dimensions 10 10 210 20
DisabledSkinType
Dragable false
Enabled true
HorizontalAnchor ANCHOR_HORIZONTAL_LEFT
HorizontalTextAlignment TEXT_ALIGNMENT_HORIZONTAL_CENTER
HoverTime 3
MaxSize 0 0
MinSize 0 0
PositionRelativeToParentClientDimensions true
Resizable false
Scrollable true
SkinType default
TextBrushFilterMode BRUSHFILTER_LINEAR
TransparencyPicking true
VerticalAnchor ANCHOR_VERTICAL_TOP
VerticalLineSpacing 2
VerticalTextAlignment TEXT_ALIGNMENT_VERTICAL_CENTER
Visible true

Text segments
{
Segment0 micross.12 1 0.1 0.1 0.1 Host
}

}

TextBox IPAddress
{
AllottedWidth 1785
BrushFilterMode BRUSHFILTER_LINEAR
ConsumeKeyboardEvents true
ContextMenuName
CursorBlinkTime 0.5
DefaultColor 1 1 1 1
DefaultFontName micross.12
Dimensions 10 40 210 20
DisabledSkinType
Dragable false
Enabled true
HorizontalAnchor ANCHOR_HORIZONTAL_LEFT
HorizontalTextAlignment TEXT_ALIGNMENT_HORIZONTAL_LEFT
HoverTime 3
KeyDownTime 0.6
KeyRepeatTime 0.04
MaskSymbol 42
MaskText false
MaxCharacters 255
MaxSize 0 0
MinSize 0 0
PositionRelativeToParentClientDimensions true
Resizable false
Scrollable true
SkinType default
TBHorizontalTextAlignment TEXT_ALIGNMENT_HORIZONTAL_LEFT
TextBrushFilterMode BRUSHFILTER_LINEAR
TextCursorDefaultSkinTypeName default
TextPosition 0 0
TransparencyPicking true
VerticalAnchor ANCHOR_VERTICAL_TOP
VerticalLineSpacing 2
VerticalTextAlignment TEXT_ALIGNMENT_VERTICAL_CENTER
Visible true

Text segments
{
Segment0 micross.12 1 0.1 0.1 0.1
}

}

Button Connect
{
AllottedWidth 96
BrushFilterMode BRUSHFILTER_LINEAR
ConsumeKeyboardEvents false
ContextMenuName
Dimensions 10 70 100 20
DisabledSkinType
Dragable false
Enabled true
HorizontalAnchor ANCHOR_HORIZONTAL_LEFT
HorizontalTextAlignment TEXT_ALIGNMENT_HORIZONTAL_CENTER
HoverTime 3
MaxSize 0 0
MinSize 0 0
PositionRelativeToParentClientDimensions true
Resizable false
Scrollable true
SkinType default
TextBrushFilterMode BRUSHFILTER_LINEAR
TransparencyPicking true
VerticalAnchor ANCHOR_VERTICAL_TOP
VerticalLineSpacing 2
VerticalTextAlignment TEXT_ALIGNMENT_VERTICAL_CENTER
Visible true

Text segments
{
Segment0 micross.12 1 0.1 0.1 0.1 Connect
}

}

Button Disconnect
{
AllottedWidth 96
BrushFilterMode BRUSHFILTER_LINEAR
ConsumeKeyboardEvents false
ContextMenuName
Dimensions 120 70 100 20
DisabledSkinType
Dragable false
Enabled true
HorizontalAnchor ANCHOR_HORIZONTAL_LEFT
HorizontalTextAlignment TEXT_ALIGNMENT_HORIZONTAL_CENTER
HoverTime 3
MaxSize 0 0
MinSize 0 0
PositionRelativeToParentClientDimensions true
Resizable false
Scrollable true
SkinType default
TextBrushFilterMode BRUSHFILTER_LINEAR
TransparencyPicking true
VerticalAnchor ANCHOR_VERTICAL_TOP
VerticalLineSpacing 2
VerticalTextAlignment TEXT_ALIGNMENT_VERTICAL_CENTER
Visible true

Text segments
{
Segment0 micross.12 1 0.1 0.1 0.1 Disconnect
}

}

TextArea ChatArea
{
AllottedWidth 190
BrushFilterMode BRUSHFILTER_LINEAR
ConsumeKeyboardEvents true
ContextMenuName
CursorBlinkTime 0.5
DefaultColor 1 1 1 1
DefaultFontName micross.12
Dimensions 10 100 210 250
DisabledSkinType
Dragable false
Enabled true
HorizontalAnchor ANCHOR_HORIZONTAL_LEFT
HorizontalTextAlignment TEXT_ALIGNMENT_HORIZONTAL_LEFT
HoverTime 3
KeyDownTime 0.6
KeyRepeatTime 0.04
MaxCharacters 255
MaxSize 0 0
MinSize 0 0
PositionRelativeToParentClientDimensions true
Resizable false
Scrollable true
SkinType default
TextBrushFilterMode BRUSHFILTER_LINEAR
TextCursorDefaultSkinTypeName default
TransparencyPicking true
VerticalAnchor ANCHOR_VERTICAL_TOP
VerticalLineSpacing 2
Visible true

Text segments
{
Segment0 micross.12 0 0 0 0
}

Child widgets
{
}

}

Button SendMessage
{
AllottedWidth 96
BrushFilterMode BRUSHFILTER_LINEAR
ConsumeKeyboardEvents false
ContextMenuName
Dimensions 10 360 210 20
DisabledSkinType
Dragable false
Enabled true
HorizontalAnchor ANCHOR_HORIZONTAL_LEFT
HorizontalTextAlignment TEXT_ALIGNMENT_HORIZONTAL_CENTER
HoverTime 3
MaxSize 0 0
MinSize 0 0
PositionRelativeToParentClientDimensions true
Resizable false
Scrollable true
SkinType default
TextBrushFilterMode BRUSHFILTER_LINEAR
TransparencyPicking true
VerticalAnchor ANCHOR_VERTICAL_TOP
VerticalLineSpacing 2
VerticalTextAlignment TEXT_ALIGNMENT_VERTICAL_CENTER
Visible true

Text segments
{
Segment0 micross.12 1 0.1 0.1 0.1 Send Message
}

}
}

Child Windows
{
}

}




Any thoughts? Remember this is all being done during the constructor of my Frame Listener - is it an issue that im setting callbacks before the render loop?
Cheers

magiconexxx

12-02-2009 19:53:41

Can you post the header code for those functions? They might not have been declared correctly...

they should look something like:

void MainGUI::ConnectHost(const QuickGUI::EventArgs &args)
{
//blah
}

kungfoomasta

12-02-2009 20:31:44

As magiconexxx says, the handler signature needs to look like this:

void className::funcName(const EventArgs& args);

From your build output, the compiler is saying it cannot find any definition for the functions you have mentioned. The obj that yields the error is MainGUI.obj, so it sounds like the function has not been defined in MainGUI.cpp.

hellaeon

12-02-2009 21:29:08

goodaye
Its definately declared and I have to admit it was playing funny buggers at first (visual studio)
I changed the function name for SendMessage to SendChatMessage


#ifndef __MAINGUI_H_
#define __MAINGUI_H_

#pragma once
#include "QuickGUIRoot.h"
#include "Ogre.h"

class MainGUI
{
private:

// gui root
QuickGUI::Root *mRoot;

// gui manager
QuickGUI::GUIManager *mGUIMgr;

// Host a server
void HostServer(const QuickGUI::EventArgs& args);

// Connect to a server
void ConnectHost(const QuickGUI::EventArgs& args);

// Disconnect from a server
void DisconnectHost(const QuickGUI::EventArgs& args);

// Send a Message
void SendChatMessage(const QuickGUI::EventArgs& args);

protected:
public:

MainGUI();
~MainGUI(void);

// start the root
void Initialize(void);

// inject mouse moved
void InjectMouseMoved(float x, float y, float z);

// inject mouse button
void InjectMousePressed(QuickGUI::MouseButtonID id);

// inject mouse button
void InjectMouseReleased(QuickGUI::MouseButtonID id);

// inject char
void InjectChar(Ogre::UTFString::unicode_char mChar);

// inject Keyboard
void InjectKeyPressed(QuickGUI::KeyCode key);

// inject Keyboard
void InjectKeyReleased(QuickGUI::KeyCode key);

// Switch off cursor
void SwitchOff(void);

// Switch on cursor
void SwitchOn(void);

// make button
void SetupInterface(void);
};

#endif


Then my MainGUI.cpp

#pragma once
#include "MainGUI.h"

MainGUI::MainGUI()
{
QuickGUI::registerScriptReader();
}

// cleanup
MainGUI::~MainGUI(void)
{
delete QuickGUI::Root::getSingletonPtr();
}

// initialise
void MainGUI::Initialize(void)
{
// the main GUI root
QuickGUI::Root *mRoot = new QuickGUI::Root();

// load skin type
QuickGUI::SkinTypeManager::getSingleton().loadTypes();

// GUI Manager
QuickGUI::GUIManagerDesc d;

// initialise Manager
mGUIMgr = QuickGUI::Root::getSingletonPtr()->createGUIManager(d);
}

// inject mouse movement
void MainGUI::InjectMouseMoved(float x, float y, float z)
{
mGUIMgr->injectMousePosition(x,y);
if(z != 0)
mGUIMgr->injectMouseWheelChange(z);
}

// inject mouse button
void MainGUI::InjectMousePressed(QuickGUI::MouseButtonID id)
{
mGUIMgr->injectMouseButtonDown(id);
}

// inject mouse button
void MainGUI::InjectMouseReleased(QuickGUI::MouseButtonID id)
{
mGUIMgr->injectMouseButtonUp(id);
}

// inject char
void MainGUI::InjectChar(Ogre::UTFString::unicode_char mChar)
{
mGUIMgr->injectChar(mChar);
}
// inject Keyboard
void MainGUI::InjectKeyPressed(QuickGUI::KeyCode key)
{
mGUIMgr->injectKeyDown(key);
}

// inject Keyboard
void MainGUI::InjectKeyReleased(QuickGUI::KeyCode key)
{
mGUIMgr->injectKeyUp(key);
}

// Switch off cursor
void MainGUI::SwitchOff(void)
{
mGUIMgr->getMouseCursor()->setVisible(false);
}

// Switch on cursor
void MainGUI::SwitchOn(void)
{
mGUIMgr->getMouseCursor()->setVisible(true);
}

// setup the actual interface
void MainGUI::SetupInterface(void)
{
// load from sheet
QuickGUI::SheetManager::getSingletonPtr()->destroySheet(mGUIMgr->getActiveSheet());
mGUIMgr->setActiveSheet(NULL);
QuickGUI::Sheet *mSheetFromFile = QuickGUI::SheetManager::getSingletonPtr()->createSheet("e:\\OgreSDK\\nd_media\\gui\\gui.sheet");
mGUIMgr->setActiveSheet(mSheetFromFile);

/* ASSIGN CALLBACKS */
// Host
QuickGUI::Widget* w = NULL;
w = mGUIMgr->getActiveSheet()->findWidget("Host");
if(w != NULL)
w->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&MainGUI::HostServer,this);

// Connect
w = mGUIMgr->getActiveSheet()->findWidget("Connect");
if(w != NULL)
w->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&MainGUI::ConnectHost,this);

// Disconnect
w = mGUIMgr->getActiveSheet()->findWidget("Disconnect");
if(w != NULL)
w->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&MainGUI::DisconnectHost,this);

// Send a message
w = mGUIMgr->getActiveSheet()->findWidget("SendMessage");
if(w != NULL)
w->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&MainGUI::SendChatMessage,this);
}

// Host a server
void HostServer(const QuickGUI::EventArgs& args) {}

// Connect to a server
void ConnectHost(const QuickGUI::EventArgs& args) {}

// Disconnect from a server
void DisconnectHost(const QuickGUI::EventArgs& args) {}

// Send a Message
void SendChatMessage(const QuickGUI::EventArgs& args) {}


is it something as simple as I have to have some code in the functions?!?!
cheers guys

magiconexxx

12-02-2009 21:40:23

// Host a server
void HostServer(const QuickGUI::EventArgs& args) {}

// Connect to a server
void ConnectHost(const QuickGUI::EventArgs& args) {}

// Disconnect from a server
void DisconnectHost(const QuickGUI::EventArgs& args) {}

// Send a Message
void SendChatMessage(const QuickGUI::EventArgs& args) {}


You declared these in the MainGUI Class, but they are not defined in your CPP file as such. They should be:

// Host a server
void MainGUI::HostServer(const QuickGUI::EventArgs& args) {}

// Connect to a server
void MainGUI::ConnectHost(const QuickGUI::EventArgs& args) {}

// Disconnect from a server
void MainGUI::DisconnectHost(const QuickGUI::EventArgs& args) {}

// Send a Message
void MainGUI::SendChatMessage(const QuickGUI::EventArgs& args) {}

hellaeon

12-02-2009 21:42:50

Oh my ******* god....

what a goose!

Im so strict about that, cant believe I did not see it haha....
Thanks

:oops: