Errors in SFML

I tried to run a simple SFML program
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#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;
}


And received [Build Error] ['sfml] Error 1
I ran a syntax check (not sure what that is honestly) and received [Warning] `nul.gcda' is not a gcov data file.
Any ideas of what is wrong? I've googled the first error and haven't found anything.
Do you have SFML correctly installed? Are you linking to it properly? That error makes no sense, it looks like your trying to open the source file with some program that expects a special file type. Also, you do realize that sf::Clock::GetElapsedTime() returns time in milliseconds and the same with sf::Sleep()? Your program is going to execute very fast...
I deleted and reinstalled it, made sure it's linked properly, and its still getting the same message. It could be expecting something, but the code is straight from an online tutorial...

And no i didn't know that returns in milliseconds.
So what's the actual error? "Build Error 1" doesn't tell us much.

I don't know what a syntax check is, either. If you don't know what it is, why/how did you do it?

Also, SFML 1.6 takes the time in seconds, whereas 2.0 takes it in milliseconds.
Thats the only error it says. I don't know what it is or how to deal with it.
I found Syntax check (in dev-c++) under 'Execute' -> 'Syntax Check' and i mentioned it in case it might help.
dev-c++


Well there's your problem.

Try a newer IDE. Dev-C++ has an ancient compiler.

And if it isn't even telling you what the error is, that's a sign that it's not worth using anyway.

wxDev-C++ has a similar feel if you don't like to change your world too much. Or you can go with MSVC++ Express. Or several other free IDEs.
To be more specific sf::Clock and sf::Sleep(...) only deal in miliseconds starting with SFML version 2.0 which is technically still a beta. I recognize this tutorial as being the first one on the SFML website and so it would be refering to version 1.6 which is the current release.

Could you copy paste all of the lines from your Linker settings? Project -> Project Options -> Additional Command-line Options. If you're using Dev-C++ then you're probably using MingW which is the default option and as the tutorial points out the order that you link these things in matters a lot.

I second Disch on switching to wxDev-C++, that's the IDE that I use and I don't have any issues with it. http://wxdsgn.sourceforge.net/

Also are "libsndfile-1.dll" and "openal32.dll" in directories that the IDE can reach? What I mean is are they in the part of the search path and does the profile this is being run under have the correct permissions to access said path?


I misread the linkers the first time
linkers i used: sfml-system.lib & sfml-system-d.lib
linkers it says to use: lsfml-system.lib & lsfml-system-d.lib
tutorial: http://www.sfml-dev.org/tutorials/1.6/start-cb.php
I'll betcha thats my problem
.lib is a MSVC thing. If you're not using MSVC, you probably shouldn't use any .lib files.

The library files for other compilers use different extensions, and iirc in gcc you don't even give it the extension in the linker options.
There's your problem, you seem to have downloaded the wrong package for that compiler\IDE setup. This would explain the non-descript error you're getting. Both Dev-C++ and wxDev-C++ use mingw.exe, a port from GCC, as their compiler, not cl.exe which is the compiler for MSVS. The two compilers have different calling conventions and other implimentation specific stuff like that so they need different libraries and aren't compatible.

Use this one:
Full SDK: http://sourceforge.net/projects/sfml/files/sfml/1.6/SFML-1.6-sdk-windows-mingw.zip/download

Or this one:
Just The Dev Files: http://sourceforge.net/projects/sfml/files/sfml/1.6/SFML-1.6-dev-windows-mingw.zip/download
Last edited on
Topic archived. No new replies allowed.