Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: link error  (Read 1925 times)

0 Members and 1 Guest are viewing this topic.

WSPSNIPER

  • Newbie
  • *
  • Posts: 28
    • View Profile
link error
« on: June 19, 2010, 03:39:12 am »
i made my own lib from a project i want to use in the future and it was giving me a bunch of undefined refs so i made it a dll instead of a static lib and now it only gives me this error

obj\Release\ScriptConsole.o:ScriptConsole.cpp:(.text$_ZN3gui6ButtonD1Ev[gui::Button::~Button()]+0xe): undefined reference to `vtable for gui::Button'
collect2: ld returned 1 exit status

here is the Button class


Code: [Select]

#ifndef _BUTTON_H
#define _BUTTON_H

#include "UIState.h"

namespace gui
{
    class DLL_EXPORT Button
    {
        public:
            Button( float x, float y, float w, float h, std::string lua_script = "", std::string text = "" );
            ~Button();

            void SetPosition(float x, float y);
            void Render(sf::RenderWindow& window);
            void Update();

            void LetLuaUpdate(bool let) { _luaUpdate = let; }

            void Lock()     { _locked = true;   }
            void UnLock()   { _locked = false;  }

            inline bool Clicked();
            inline bool Hovering();
            inline bool Locked()    { return _locked; }

            void SetText(std::string text);
            float GetX() const { return _rect.Left;         }
            float GetY() const { return _rect.Top;          }
            float GetH() const { return _rect.GetHeight();  }
            float GetW() const { return _rect.GetWidth();   }

        private:
            sf::Font        _font;
            sf::Shape       _button;
            sf::Shape       _hoverRect;
            std::string     _textStr;
            std::string     _luaScript;
            sf::String      _text;
            bool            _locked;
            bool            _luaUpdate;
            sf::FloatRect   _rect;
            UIState*        _ui;
            LuaManager*     _lua;
    };
}

#endif




and the cpp file



Code: [Select]


#include "Button.h"

using namespace gui;


Button::Button(float x, float y, float w, float h, std::string lua_script, std::string text)
:
_ui(UIState::GetInst()),
_lua(LuaManager::GetInst()),
_rect(x,y,x+w,y+h)
{

    _textStr = text;
    _luaScript = lua_script;
    _luaUpdate = true;
    _font.LoadFromFile("system.ttf", 20);
    _text.SetFont(_font);

    _text.SetText(_textStr);
_text.SetCenter((_text.GetRect().Left + (_text.GetRect().Right - _text.GetRect().Left)/2),
(_text.GetRect().Top + (_text.GetRect().Bottom - _text.GetRect().Top)/2));

    _text.SetScale(0.45f,0.45f);

    SetPosition(x, y);
}

Button::~Button() {}

void Button::Render(sf::RenderWindow& window)
{
    window.Draw(_button);
if(Hovering())
window.Draw(_hoverRect);
window.Draw(_text);
}


void Button::SetPosition(float x, float y)
{
    _rect.Left = x;
    _rect.Right = x + _rect.GetWidth();
    _rect.Top = y;
    _rect.Bottom = y + _rect.GetHeight();
    _button = sf::Shape::Rectangle(_rect.Left, _rect.Top, _rect.Right, _rect.Bottom, sf::Color(200, 200, 200));

_hoverRect = sf::Shape::Rectangle(_rect.Left, _rect.Top, _rect.Right, _rect.Bottom, sf::Color(0,0,200,60));

_text.SetPosition(_rect.Left + _rect.GetWidth()/2, _rect.Top + _rect.GetHeight()/2);
}


void Button::Update()
{
    if(_luaUpdate)
    {
        if(Clicked())
        {
            _lua->DoFile(_luaScript);
            _ui->itemActive = 2;
        }
    }
}

bool Button::Clicked()
{
    return (
_ui->mouseX >= _rect.Left   &&
_ui->mouseX <= _rect.Right  &&
_ui->mouseY >= _rect.Top    &&
_ui->mouseY <= _rect.Bottom &&
_ui->mouseDown              &&
_ui->itemActive <= 1          // only allow one click a click (lol)
);
}

bool Button::Hovering()
{
    return (
_ui->mouseX >= _rect.Left   &&
_ui->mouseX <= _rect.Right  &&
_ui->mouseY >= _rect.Top    &&
_ui->mouseY <= _rect.Bottom
);
}

void Button::SetText(std::string text)
{
    _text.SetText(text);
}

WSPSNIPER

  • Newbie
  • *
  • Posts: 28
    • View Profile
SOLVED
« Reply #1 on: June 19, 2010, 03:56:37 am »
i found my problem, i did not link properly to my lib in the release build and that caused this :)

 

anything