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

Author Topic: Problem with compiling AniSprite  (Read 2711 times)

0 Members and 1 Guest are viewing this topic.

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Problem with compiling AniSprite
« on: January 08, 2012, 06:20:09 pm »
Hey, I'm trying to compile the following code:
Code: [Select]

#include "SFML/Graphics.hpp"
#include "SFML/System.hpp"
#include "AniSprite.h"

int main()
{
    sf::RenderWindow App(sf::VideoMode(640, 420,32), "Test");

sf::Image Image;

if (!Image.LoadFromFile("untitled1.bmp"))
   return 1;
Image.CreateMaskFromColor(sf::Color::Black);


AniSprite Sprite(Image,93,96);
Sprite.SetLoopSpeed(0.007); //60 fps




while(App.IsOpened())
{
    sf::Event Event;

    while (App.GetEvent(Event))
    {
        if (Event.Type == sf::Event::Closed)
                App.Close();
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::A))
                Sprite.Play();
        else if ((Event.Type == sf::Event::KeyReleased) && (Event.Key.Code == sf::Key::A))
                Sprite.Stop();

    }

    App.Clear();
    Sprite.Update();
    App.Draw(Sprite);
    App.Display();
}
}

and I get
Code: [Select]

/home/aballofwin/Downloads/frame_anim_animated/sample/main(1).o||In function `main':|
main(1).cpp|| undefined reference to `AniSprite::AniSprite(sf::Image const&, int, int)'|
main(1).cpp|| undefined reference to `AniSprite::SetLoopSpeed(float)'|
main(1).cpp|| undefined reference to `AniSprite::Play()'|
main(1).cpp|| undefined reference to `AniSprite::Stop()'|
main(1).cpp|| undefined reference to `AniSprite::Update()'|
main(1).cpp|| undefined reference to `AniSprite::~AniSprite()'|
main(1).cpp|| undefined reference to `AniSprite::~AniSprite()'|
||=== Build finished: 7 errors, 0 warnings ===|


and I was wondering if there's a linker option I'm missing, or something else?

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Problem with compiling AniSprite
« Reply #1 on: January 08, 2012, 06:36:43 pm »
You are probably missing a lib file.
TGUI: C++ SFML GUI

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Problem with compiling AniSprite
« Reply #2 on: January 08, 2012, 06:45:53 pm »
The following files that i have in the directory of the main file are:
anim.hpp
animated.cpp
animated.hpp
AniSprite.cpp
AniSprite.h
frame.cpp
frame.hpp
main(1).cpp
pausableclock.hpp

sfml-audio.dll
sfml-graphics.dll
sfml-system.dll
sfml-window.dll

untitled1.bmp

anything you notice is missing from that?

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Problem with compiling AniSprite
« Reply #3 on: January 08, 2012, 07:02:05 pm »
Have you included AniSprite.cpp in your project?
Putting it in the same folder isn't enough.
TGUI: C++ SFML GUI

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Problem with compiling AniSprite
« Reply #4 on: January 08, 2012, 07:39:47 pm »
Cheers :) I put #include "AniSprite.cpp" at the top

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Problem with compiling AniSprite
« Reply #5 on: January 08, 2012, 08:04:06 pm »
Quote
I put #include "AniSprite.cpp" at the top

A cpp file is a source file and shouldn't be included like a header file.
If it works for you then its good, but it is not the correct way to do it.

You should add it just like the main.cpp file or any other source file.
TGUI: C++ SFML GUI