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

Author Topic: Problem with the SFML Game Development book  (Read 1936 times)

0 Members and 2 Guests are viewing this topic.

Ilman

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Problem with the SFML Game Development book
« on: February 15, 2015, 07:51:22 pm »
Hi all, it feels like forever since I last posted here.  :D
Anyways, I've recently purchased SFML Game Development and I have to say, it's really helpful and interesting to follow.  ;D
I've been trying to write down all the code in each chapter (with the assistance of the github source code) and it's been going well until a few hours ago.
I just finished Chapter 5 and, while it was a bit complicated to follow, I believe I got the gist of it...
After I read through the last pages of the chapter and wrote down all the code, I was faced with ~45 errors like this one:
obj\Debug\Application.o||In function `ZN11ApplicationC2Ev':|
D:\SFML projects\Book_PartV\Application.cpp|19|undefined reference to `State::Context::Context(sf::RenderWindow&, ResourceHolder<sf::Texture, Textures::ID>&, ResourceHolder<sf::Font, Fonts::ID>&, Player&)'
|
All of these errors are inside Application.cpp.

Full error log can be seen here: http://pastebin.com/vEsPtA1D

I've noticed that the errors are connected to class State and it's struct Context...and I've compared both State.cpp and State.hpp with the ones on github several times.
I've been searching for the problem for at least an hour and I couldn't find anything.

If anyone wants the sources, I'll upload them on Pastebin.
Everything is written on a clean installation of Code::Blocks and compiled on MinGW and GCC 4.9.2 on Windows 8.1.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Problem with the SFML Game Development book
« Reply #1 on: February 15, 2015, 08:22:31 pm »
Without the code, all I personally can say is that it's a linker error. It can't find the mentioned functions of State.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Problem with the SFML Game Development book
« Reply #2 on: February 15, 2015, 08:24:42 pm »
Make sure you do a full rebuild, so there are no old object files being used.
Next you nees to make sure that you include all the header files properly and at the right place. Especially pay attention to forward declared types.

If that doesn't help you'll have to provide the source code.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ilman

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Problem with the SFML Game Development book
« Reply #3 on: February 15, 2015, 09:12:14 pm »
Make sure you do a full rebuild, so there are no old object files being used.
Next you nees to make sure that you include all the header files properly and at the right place. Especially pay attention to forward declared types.

If that doesn't help you'll have to provide the source code.
After checking through the files, included in the project, I noticed that State.cpp wasn't included...
I really hate it when these dumb mistakes happen and I can't find them for hours...sorry for the inconvenience.  :(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Problem with the SFML Game Development book
« Reply #4 on: February 16, 2015, 01:14:33 am »
Everybody gets stumped from time to time, thus this forum exists so people who have experienced similar issues can help others. ;)
Glad you could figure it out.

What one should take away from this is: If you get an unresolved reference to your own source files, it often means that you didn't add them to the project/makefile/etc.
If you get an unresolved reference to a library, you usually didn't link the right library properly.
« Last Edit: February 16, 2015, 01:16:21 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/