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

Author Topic: CodeLite with SFML  (Read 1891 times)

0 Members and 1 Guest are viewing this topic.

Helik

  • Newbie
  • *
  • Posts: 1
    • View Profile
CodeLite with SFML
« on: August 26, 2017, 07:12:00 pm »
Hello there!

I use IDE CodeLite and wrote the following code:

Code: [Select]
#include <SFML/Graphics.hpp>
 using namespace sf;
int main()
{
    RenderWindow window(VideoMode(550, 200), "test");
   
    Texture t;
    t.loadFromFile("images\hero.png");
   
    Sprite s;
    s.setTexture(t);
    s.setPosition(50 , 25);
 
   while (window.isOpen())
   {
      Event event;
      while (window.pollEvent(event))
      {
         if (event.type == Event::Closed)
            window.close();
      }
 
      window.clear();
      window.draw(s);
      window.display();
   }
 
   return 0;
}

And when i click "Run" enter goes error:

Quote
F:/MyProject/SFML/First/main.cpp:8: undefined reference to `sf::Texture::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Rect<int> const&)'


What's wrong?
I was looking for an explanation, but I couldn't find
The program was set up as stated here: https://en.sfml-dev.org/forums/index.php?topic=18820.0
When i use code, how here: https://www.sfml-dev.org/tutorials/2.4/start-cb.php it worked
If need something to add, I'll do  ;D


Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: CodeLite with SFML
« Reply #1 on: August 27, 2017, 01:35:31 am »
It looks like you're mixing up builds.
It seems to be building in Debug mode whereas you are linking to release builds of SFML.
It seems that you have defined "SFML_STATIC" but are not linking to static builds of SFML.
If you are building statically, you also need to link the modules' dependencies.

You mentioned this tutorial; this information is all there ;)
https://www.sfml-dev.org/tutorials/2.4/start-cb.php#creating-and-configuring-a-sfml-project
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*