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

Author Topic: Undefined reference?  (Read 2310 times)

0 Members and 2 Guests are viewing this topic.

seerex

  • Newbie
  • *
  • Posts: 12
    • View Profile
Undefined reference?
« on: April 21, 2011, 06:03:54 pm »
hi all,

i recently started looking into the world of programming. i have for a long time though about it, and especially game programming tends to be my thing, hence i was redirected to using SFML through the cplusplus.com forum.

Anywhoo, i am currently following the tutorial on how to set up SFML with codeblocks and the newest version 4.4 of mingw.

This is the code the tutorial shows me to try and use.

#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

But when i try and compile i get - undefined reference to sf::sleep and sf::Clock.

It might have something to do with my build options and other link options, as it is kinda the part where the tutorial lost me. Currently i have
-isfml-system

But not sure thats sufficient? tbh the tutorial does go into the subject a bit on these and clearly states that there are several types of this system thingy all depending on which things you use in your code.

And i have no idea what im using and what it requires in order to compile and run :P

Thanks for taking your time to read.
Best regards

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Undefined reference?
« Reply #1 on: April 21, 2011, 06:06:13 pm »
For sf::Clock, the sfml-system library is enough. However, the correct linker flag is -lsfml-system and not -isfml-system.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

seerex

  • Newbie
  • *
  • Posts: 12
    • View Profile
Undefined reference?
« Reply #2 on: April 21, 2011, 06:12:19 pm »
Quote from: "Nexus"
For sf::Clock, the sfml-system library is enough. However, the correct linker flag is -lsfml-system and not -isfml-system.


ooh lol i thought it was a capital "i" and not an "l" :P

Alright something happens now, i tried to compile and run it (from codeblocks, guessing thats what i have to do), and even though it still pops up an error, although the console do run.

"program couldnt start since sfml-system.dll is missing on the computer."

The tutorial says i need to copy that file to the executeable directory, which i assume is the folder my c++ codeblocks project is in? but i cant seem to find the exact file.

On a side-note, any specefic place in the folder the file needs to be in once i get it located? :)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Undefined reference?
« Reply #3 on: April 21, 2011, 06:14:56 pm »
Quote from: "seerex"
That makes any sense to you?
Yes. When you link dynamically, you must tell your application where the dynamic libraries (in your case the .dll files) are located. You could set this globally in the PATH environment variable, or you could move the SFML .dll files to C:/Windows/System32 or to your executable directory.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

seerex

  • Newbie
  • *
  • Posts: 12
    • View Profile
Undefined reference?
« Reply #4 on: April 21, 2011, 06:18:48 pm »
Quote from: "Nexus"
Quote from: "seerex"
That makes any sense to you?
Yes. When you link dynamically, you must tell your application where the dynamic libraries (in your case the .dll files) are located. You could set this globally in the PATH environment variable, or you could move the SFML .dll files to C:/Windows/System32 or your executable directory.


Well, i cant seem to find that file. I tried to copy the SFML file into my codeblocks project folder, but that didnt solve the problem. cant find any specefic file named system.dll.

Thanks for so swift replies though!! amazing :)

seerex

  • Newbie
  • *
  • Posts: 12
    • View Profile
Undefined reference?
« Reply #5 on: April 21, 2011, 06:56:01 pm »
Yiiippiiie its fixed :)

sorry for bothering you with the issue. seems like that even if i search for the file in windows search it cant find it, i found it by manually looking through each folder and file eventually.

Then i just copied the file in the codeblocks project.

I just wrote what i did if anyone else like me should stumble upon it :)

Thanks for your help chap!