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

Author Topic: Sprite Help  (Read 4167 times)

0 Members and 2 Guests are viewing this topic.

armaskywalker

  • Newbie
  • *
  • Posts: 5
    • View Profile
Sprite Help
« on: February 13, 2012, 09:11:27 pm »
Hello to all users, I have a compile error on codeblocks about test Graphics from SFML tutorial website.
i'm sorry for my poor english and thanks for response

Test:
Code: [Select]
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;

int main()
{
   // Create the main rendering window
    sf::RenderWindow Finestra(sf::VideoMode(800, 600, 32), "SFML Graphics Test");
   //Carico l'img da file
   sf::Image Image;
   if(!Image.LoadFromFile("wall.png"))
   return EXIT_FAILURE;
   //Creo la sprite
   sf::Sprite Sprite(Image);
   //Cambio le proprietà
   Sprite.SetColor(sf::Color(0,255,255,128));
   Sprite.SetPosition(200.f,100.f);
   Sprite.SetScale(2.f,2.f);
   //Inizio Loop Gioco
   while (Finestra.IsOpened())
   {
       //Eventi
       sf::Event Eventi;
       while (Finestra.GetEvent(Eventi))
       {
           //Chiude La finestra: exit **esci
           if(Eventi.Type ==  sf::Event::Closed)
           Finestra.Close();
       }

       //Tempo
       float ElapsedTime = Finestra.GetFrameTime();
       //Muovi lo sprite
       if(Finestra.GetInput().IsKeyDown(sf::Key::Left))  Sprite.Move(-100 * ElapsedTime,0);
       if(Finestra.GetInput().IsKeyDown(sf::Key::Right)) Sprite.Move(100 * ElapsedTime,0);
       if(Finestra.GetInput().IsKeyDown(sf::Key::Up))    Sprite.Move(0, -100 * ElapsedTime);
       if(Finestra.GetInput().IsKeyDown(sf::Key::Down))  Sprite.Move(0, 100 * ElapsedTime);
       //Ruota lo sprite
       if(Finestra.GetInput().IsKeyDown(sf::Key::Add))   Sprite.Rotate(- 100 * ElapsedTime);
       if (Finestra.GetInput().IsKeyDown(sf::Key::Subtract)) Sprite.Rotate(+ 100 * ElapsedTime);
       //Pulisci schermo
       Finestra.Clear();
       //Mostra lo sprite
       Finestra.Draw(Sprite);
       //Mostra tutto su schermo
       Finestra.Display();
   }
    return EXIT_SUCCESS;
}


Errors:42
Code: [Select]
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Sprite.o):Sprite.cpp|| multiple definition of `sf::Sprite::Sprite(sf::Image const&, sf::Vector2<float> const&, sf::Vector2<float> const&, float, sf::Color const&)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000126.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| multiple definition of `sf::Image::Image()'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000075.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| multiple definition of `sf::Image::~Image()'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000080.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| multiple definition of `sf::Image::LoadFromFile(std::string const&)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000060.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Color.o):Color.cpp|| multiple definition of `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000053.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::~Drawable()'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000162.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::SetPosition(float, float)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000141.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::SetScale(float, float)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000153.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::SetColor(sf::Color const&)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000151.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::Move(float, float)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000145.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::Rotate(float)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000150.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Sprite.o):Sprite.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Sprite.o):Sprite.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Sprite.o):Sprite.cpp:(.text$_ZN2sf6SpriteD0Ev[sf::Sprite::~Sprite()]+0x15d)||undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Sprite.o):Sprite.cpp:(.eh_frame+0x12)||undefined reference to `__gxx_personality_v0'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| more undefined references to `_Unwind_Resume' follow|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp:(.eh_frame+0x12)||undefined reference to `__gxx_personality_v0'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp:(.eh_frame+0x11)||undefined reference to `__gxx_personality_v0'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(ImageLoader.o):ImageLoader.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(ImageLoader.o):ImageLoader.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(ImageLoader.o):ImageLoader.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(ImageLoader.o):ImageLoader.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(ImageLoader.o):ImageLoader.cpp|| undefined reference to `_Unwind_Resume'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(ImageLoader.o):ImageLoader.cpp|| more undefined references to `_Unwind_Resume' follow|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(ImageLoader.o):ImageLoader.cpp:(.eh_frame+0x12)||undefined reference to `__gxx_personality_v0'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(GraphicsContext.o):GraphicsContext.cpp:(.eh_frame+0x11)||undefined reference to `__gxx_personality_v0'|
||=== Build finished: 42 errors, 0 warnings ===|


Thanks :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sprite Help
« Reply #1 on: February 13, 2012, 10:40:14 pm »
You're linking several versions of the SFML libraries (static and dynamic). Choose just one.

And your version of MinGW might not be compatible with the one that was used to compile SFML (see the tutorial).
Laurent Gomila - SFML developer

armaskywalker

  • Newbie
  • *
  • Posts: 5
    • View Profile
more
« Reply #2 on: February 14, 2012, 11:52:16 am »
Now i have download MinGW-with-gcc-4.4.zip (34.9 MB) from tutorial
and put in /MinGW/Include -> /SFML/include, /MinGW/lib -> /SFML/lib
And have this errors:31
Code: [Select]
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Sprite.o):Sprite.cpp|| multiple definition of `sf::Sprite::Sprite(sf::Image const&, sf::Vector2<float> const&, sf::Vector2<float> const&, float, sf::Color const&)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000126.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| multiple definition of `sf::Image::Image()'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000075.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| multiple definition of `sf::Image::~Image()'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000080.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Image.o):Image.cpp|| multiple definition of `sf::Image::LoadFromFile(std::string const&)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000060.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Color.o):Color.cpp|| multiple definition of `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000053.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::~Drawable()'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000162.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::SetPosition(float, float)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000141.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::SetScale(float, float)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000153.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::SetColor(sf::Color const&)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000151.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::Move(float, float)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000145.o)|| first defined here|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics-s.a(Drawable.o):Drawable.cpp|| multiple definition of `sf::Drawable::Rotate(float)'|
..\..\..\..\MinGW\include\SFML-1.6\lib\libsfml-graphics.a(d000150.o)|| first defined here|
obj\Debug\main.o||In function `main':|
C:\Program Files (x86)\CodeBlocks\project\SFML\test\test2\main.cpp|8|undefined reference to `__gxx_personality_sj0'|
C:\Program Files (x86)\CodeBlocks\project\SFML\test\test2\main.cpp|8|undefined reference to `_Unwind_SjLj_Register'|
C:\Program Files (x86)\CodeBlocks\project\SFML\test\test2\main.cpp|10|undefined reference to `_Unwind_SjLj_Resume'|
C:\Program Files (x86)\CodeBlocks\project\SFML\test\test2\main.cpp|50|undefined reference to `_Unwind_SjLj_Unregister'|
C:\Program Files (x86)\CodeBlocks\project\SFML\test\test2\main.cpp|50|undefined reference to `_Unwind_SjLj_Resume'|
obj\Debug\main.o||In function `~Sprite':|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\SFML\Graphics\Sprite.hpp|45|undefined reference to `__gxx_personality_sj0'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\SFML\Graphics\Sprite.hpp|45|undefined reference to `_Unwind_SjLj_Register'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\SFML\Graphics\Sprite.hpp|45|undefined reference to `_Unwind_SjLj_Resume'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\SFML\Graphics\Sprite.hpp|45|undefined reference to `_Unwind_SjLj_Unregister'|
||=== Build finished: 31 errors, 0 warnings ===|

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sprite Help
« Reply #3 on: February 14, 2012, 11:57:11 am »
You're still linking to more than one version of SFML.

And your version of MinGW is still wrong. What did you do to make Code::Blocks use your new version of MinGW?
Laurent Gomila - SFML developer

armaskywalker

  • Newbie
  • *
  • Posts: 5
    • View Profile
Sprite Help
« Reply #4 on: February 14, 2012, 12:28:02 pm »
i have use this tutorial:


Edit:
Maybe resolved, i have copy SFML/lib/.ddl in /bin/debug project folder
and add in linker -sfml-window,graphic ecc..

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Sprite Help
« Reply #5 on: February 21, 2012, 08:14:14 pm »
Try SFML Coder, even though it seems he missed a step when building the libraries. Or just didn't mention it.



Also make sure the older versions of SFML aren't linked to in your current project because this can get very annoying as you found out. :)

Here's the list of libs to include. Be sure to drop the [ ] from the names and change in and out the -s and -d depending on what you need.
libsfml-graphics[-s][-d].a
libsfml-window[-s][-d].a
libsfml-audio[-s][-d].a
libsfml-network[-s][-d].a
libsfml-system[-s][-d].a
I have many ideas but need the help of others to find way to make use of them.

 

anything