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

Author Topic: Why do I get this error with 'sf::clock' and other sf:: codes  (Read 2964 times)

0 Members and 3 Guests are viewing this topic.

FlamingBurrito15

  • Newbie
  • *
  • Posts: 2
    • View Profile
Why do I get this error with 'sf::clock' and other sf:: codes
« on: November 24, 2017, 10:25:51 pm »
Hello I have an issue with my code.
sf::Clock clock;
sf::Time elapsed = clock.restart();
i get this error.
Quote
undefined reference to `sf::Clock::Clock()'
Quote
undefined reference to `sf::Clock::restart()'
It is also giving me similar error with other "sf::" lines but that might be the clock code causing that.
I am using Code::Blocks with SFML to do this if anyone knows how to fix this please help me.

Kerachi

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: Why do I get this error with 'sf::clock' and other sf:: codes
« Reply #1 on: November 24, 2017, 11:11:07 pm »
If you have readed the turorial about time: https://www.sfml-dev.org/tutorials/2.4/system-time.php, then you would know that you can't do this:

sf::Time elapsed = float;

but rather:

sf::Time timee = sf::seconds(clock.restart().asSeconds());

Because time variable, was already defined.

Or just simply:

float time = clock.restart();

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Why do I get this error with 'sf::clock' and other sf:: codes
« Reply #2 on: November 24, 2017, 11:18:50 pm »
Something is wrong with your linker settings, you should double check or show them here.
Back to C++ gamedev with SFML in May 2023

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Why do I get this error with 'sf::clock' and other sf:: codes
« Reply #3 on: November 24, 2017, 11:20:18 pm »
Quote
If you have readed the turorial
Which you obviously didn't do.

Please avoid posting unrelated and wrong information, and start reading the tutorials that you mention ;D
Laurent Gomila - SFML developer

FlamingBurrito15

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Why do I get this error with 'sf::clock' and other sf:: codes
« Reply #4 on: November 24, 2017, 11:39:18 pm »
Something is wrong with your linker settings, you should double check or show them here.

Yeah I just checked my linker settings and nothing is linked. Is there a specific file that I have to link to it?

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Back to C++ gamedev with SFML in May 2023

 

anything