Sign in to follow this  

MSVC++ linking troubles

This topic is 3629 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

Hello there. Im an intermediate C++ coder. My IDE of choice is MSVC++. Right now im learning how to use HGE (2d graphics library) with Guichan (GUI library supporting HGE). Admittedly, im quite new to the whole concept of organizing my project code. Ive read the 'Organizing Code Files in C and C++' on GameDev and gathered as much information as i could. However, im having a problem with using classes defined/declared in separate files which i cant seem to resolve. I have a class inheriting from ActionListener and implementing action function. ButtonActionListener.h:
#ifndef INC_BUTTONACTIONLISTENER_H
#define INC_BUTTONACTIONLISTENER_H

#include <guichan.hpp>
#include <guichan/hge.hpp>

class ButtonActionListener : public gcn::ActionListener
{
public:
void gActionListener(void);

void action(const gcn::ActionEvent& actionEvent);
};

#endif /* INC_BUTTONACTIONLISTENER_H */

ButtonActionListener.cpp:
#include "ButtonActionListener.h"
#include "main.h" // extern imageButton is in here

void ButtonActionListener::gActionListener(void)
{
}

void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == imageButton)
{

}
}

An external pointer to ButtonActionListener is declared in in main.h:
#include "ButtonActionListener.h"

extern ButtonActionListener* buttonActionListener;

Now i want to use this pointer as a handle for new ButtonActionListener object in funcion initWidgets() located in initWidgets.h and initWidgets.cpp. initWidgets.cpp:
#include "main.h"

ButtonActionListener* buttonActionListener;
(...)
void initWidgets()
{
(...)
buttonActionListener = new ButtonActionListener();
}

This is where it fails with this error: initWidgets.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ButtonActionListener::action(class gcn::ActionEvent const &)" (?action@ButtonActionListener@@UAEXABVActionEvent@gcn@@@Z) Any help appreciated.

Share this post


Link to post
Share on other sites
Hahaha, thats grand! Im searching all over the internet for linking errors, trying various include configurantions when its such a simple mistake! Thanks, and sorry for wasting your time.

Share this post


Link to post
Share on other sites

This topic is 3629 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this