SFML Help

Pages: 12
Mar 8, 2012 at 6:35pm
Hello, I'm trying to learn SFML, and I came across a problem. I'm using Code::Blocks, and I was trying to compile a very simple program (below). I'm not positive if I set it up right, and it gave me the following error: "-------------- Build: Debug in ddd ---------------

Linking stage skipped (build target has no object files to link)
Nothing to be done.
"
What exactly did I do wrong? I'm using the GNU GCC Compiler.

Code:

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;
}


Thanks,
Westbrook
Mar 8, 2012 at 7:49pm
It looks like you didn't add that source file to your project.

I forget how to do it in C::B, but look around for a "Add existing file to project" option and add your source file.
Mar 8, 2012 at 8:33pm
I did, and it got rid of that error, and gave me a lot more. What kind of project template do you mean? Or do you mean something than a project template?
Mar 8, 2012 at 9:00pm
What are the new errors?
Mar 8, 2012 at 9:02pm
-------------- Build: Debug in ddd ---------------

Compiling: ..\Untitled1.c
In file included from C:/SFML-1.6/include/SFML/SYSTEM.hpp:32,
from C:\Documents and Settings\Ezra (big E)\My Documents\C++ Projects\Untitled1.c:1:
C:/SFML-1.6/include/SFML/Config.hpp:122:19: climits: No such file or directory
In file included from C:/SFML-1.6/include/SFML/SYSTEM.hpp:32,
from C:\Documents and Settings\Ezra (big E)\My Documents\C++ Projects\Untitled1.c:1:
C:/SFML-1.6/include/SFML/Config.hpp:124: error: syntax error before "sf"
C:/SFML-1.6/include/SFML/Config.hpp:125: error: syntax error before '{' token
C:/SFML-1.6/include/SFML/Config.hpp:131:10: #error No 8 bits integer type for this platform
C:/SFML-1.6/include/SFML/Config.hpp:145:10: #error No 16 bits integer type for this platform
C:/SFML-1.6/include/SFML/Config.hpp:159:10: #error No 32 bits integer type for this platform
In file included from C:/SFML-1.6/include/SFML/SYSTEM.hpp:33,
from C:\Documents and Settings\Ezra (big E)\My Documents\C++ Projects\Untitled1.c:1:
C:/SFML-1.6/include/SFML/System/Clock.hpp:35: error: syntax error before '{' token
C:/SFML-1.6/include/SFML/System/Clock.hpp: In function `GetElapsedTime':
C:/SFML-1.6/include/SFML/System/Clock.hpp:55: warning: empty declaration
C:/SFML-1.6/include/SFML/System/Clock.hpp:63: error: syntax error before "private"
In file included from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdarg.h:6,
from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windows.h:47,
from C:/SFML-1.6/include/SFML/System/Win32/Mutex.hpp:32,
from C:/SFML-1.6/include/SFML/System/Mutex.hpp:36,
from C:/SFML-1.6/include/SFML/SYSTEM.hpp:35,
from C:\Documents and Settings\Ezra (big E)\My Documents\C++ Projects\Untitled1.c:1:
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stdarg.h:106: error: storage class specified for parameter `__gnuc_va_list'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stdarg.h:106: error: syntax error before "va_list"
In file included from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windows.h:48,
from C:/SFML-1.6/include/SFML/System/Win32/Mutex.hpp:32,
from C:/SFML-1.6/include/SFML/System/Mutex.hpp:36,
from C:/SFML-1.6/include/SFML/SYSTEM.hpp:35,
from C:\Documents and Settings\Ezra (big E)\My Documents\C++ Projects\Untitled1.c:1:
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:222: error: storage class specified for parameter `DWORD'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:223: error: storage class specified for parameter `WINBOOL'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:223: error: storage class specified for parameter `PWINBOOL'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:223: error: storage class specified for parameter `LPWINBOOL'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:227: error: storage class specified for parameter `WINBOOL'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:227: error: redefinition of parameter 'WINBOOL'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:223: error: previous definition of 'WINBOOL' was here
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:227: error: syntax error before "BOOL"
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:231: error: storage class specified for parameter `BYTE'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:233: error: storage class specified for parameter `BOOL'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:233: error: syntax error before '*' token
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:234: error: storage class specified for parameter `WORD'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:235: error: storage class specified for parameter `FLOAT'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:236: error: storage class specified for parameter `FLOAT'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:236: error: conflicting types for 'FLOAT'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:235: error: previous definition of 'FLOAT' was here
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:236: error: syntax error before '*' token
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:237: error: storage class specified for parameter `BYTE'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:237: error: conflicting types for 'BYTE'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:231: error: previous definition of 'BYTE' was here
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:237: error: syntax error before '*' token
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:238: error: storage class specified for parameter `PINT'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:238: error: storage class specified for parameter `LPINT'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:239: error: storage class specified for parameter `WORD'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:239: error: conflicting types for 'WORD'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:234: error: previous definition of 'WORD' was here
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:239: error: syntax error before '*' token
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:240: error: storage class specified for parameter `LPLONG'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:241: error: storage class specified for parameter `DWORD'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:241: error: conflicting types for 'DWORD'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:222: error: previous definition of 'DWORD' was here
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:241: error: syntax error before '*' token
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:242: error: storage class specified for parameter `PCVOID'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:242: error: storage class specified for parameter `LPCVOID'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:243: error: storage class specified for parameter `INT'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:244: error: storage class specified for parameter `UINT'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:244: error: storage class specified for parameter `PUINT'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:244: error: storage class specified for parameter `LPUINT'

Mar 8, 2012 at 9:02pm
In file included from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stddef.h:6,
from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/string.h:24,
from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/winnt.h:37,
from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windef.h:246,
from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/windows.h:48,
from C:/SFML-1.6/include/SFML/System/Win32/Mutex.hpp:32,
from C:/SFML-1.6/include/SFML/System/Mutex.hpp:36,
from C:/SFML-1.6/include/SFML/SYSTEM.hpp:35,
from C:\Documents and Settings\Ezra (big E)\My Documents\C++ Projects\Untitled1.c:1:
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stddef.h:213: error: storage class specified for parameter `size_t'
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stddef.h:325: error: storage class specified for parameter `wchar_t'
Mar 8, 2012 at 9:19pm
I think it's about time someone makes a nice SFML tutorial here in the articles, if it's not already done. There's been quite a few issues with people getting it set up lately
Mar 8, 2012 at 9:20pm
Is this somehow using gcc instead of g++ to try to compile?
Mar 8, 2012 at 9:21pm
Should I be using g++? I am using gcc. It said to online.
Mar 8, 2012 at 9:25pm
Wait, how do i use g++?
Mar 8, 2012 at 9:26pm
In CodeBlocks, you must use a .cpp extension on C++ source code for it to use the C++ compiler, otherwise it uses the C compiler.
Mar 8, 2012 at 9:38pm
Well, that helped a lot, but now I've got:


Execution of 'devcpp.exe -Wall -g -fexceptions -DSFML_DYNAMIC -g -IC:\SFML-1.6\include -I-lsfml-audio -c "C:\Documents and Settings\xxx\My Documents\C++ Projects\Untitled1.cpp" -o obj\Debug\Untitled1.o' in 'C:\Documents and Settings\Ezra (big E)\My Documents\C++ Projects\ddd' failed.
Mar 8, 2012 at 10:04pm
westbrook wrote:
Execution of 'devcpp.exe


Something is trying to execute the Dev-C++ (eww) IDE as a compiler... I'm not sure if you setup SFML wrong or REALLY messed up some setting in CodeBlocks. Try re-installing SFML, using g++.exe (inside Codeblocks/mingw/bin/) as the C++ compiler, and gcc.exe (same spot) for the C compiler.
Mar 8, 2012 at 10:23pm
What should I be using for the static and dynamic library linkers?
Mar 8, 2012 at 10:31pm
Now I can compile and run the program, but it says that "This application has failed to start because SFML-system.dll was not found. Reinstalling the program may fix this problem" or something like that. What do I do?
Mar 8, 2012 at 11:07pm
Seems like I'm almost there. Now I can't build it, and the only error is: "cannot find -lsfml-system", what should I do now?
Mar 8, 2012 at 11:16pm
I think it's about time someone makes a nice SFML tutorial here in the articles, if it's not already done. There's been quite a few issues with people getting it set up lately
# pacman -S sfml
$ yaourt -S sfml-bin32
$ yaourt -S sfml-bin64
'sfml' refers to the 2.0 version
'sfml-bin{32,64}' to 1.6
Done.

If you want both (they conflict)
You may edit the PKGBUILD to use another directory (by instance SFML-1.6)
That means that you will need to change the headers to point to SFML-1.5 instead.
perl 's#<SFML/#<SFML-1.6#' should work

The simbolic links are also missing, so you need
1
2
cd "${pkgdir}/usr/lib/"
ln -s libsfml-audio.so.1.6 libsfml-1.6-audio.so #same for graphics network system window 

So to link agains 2.0 (gcc) -lsfml-library
and 1.6 -lsfml-1.6-library

This application has failed to start because SFML-system.dll was not found. Reinstalling the program may fix this problem" or something like that. What do I do?
You may try:
_ reinstall the application
_ find out where are SFML-*.dll, and move/copy them to the library path
_ link statically.
Mar 9, 2012 at 2:51am
As to your last quote, how?
Mar 9, 2012 at 7:02am
Oops, if you can't find the library you can link it statically. That's for when you execute and it says that it cannot find it.

The libraries are probably in C:/SFML-1.6/lib/
You could also say to look for them there. (for gcc -L"C:/SFML-1.6/lib/" if that is how you write a path in windows)

Also take a look at http://sfml-dev.org/tutorials/1.6/start-cb.php
Important: this release of SFML was compiled with gcc 4.4, which makes the SFML libraries not compatible with the old gcc 3.4.5. The MinGW team hasn't released a full package including gcc 4.4 yet, so here is one that you can use: mingw-with-gcc-4.4.zip .
Last edited on Mar 9, 2012 at 7:03am
Mar 9, 2012 at 8:05pm
This is what I have now:


Linking console executable: bin\Debug\blah.exe
mingw32-g++.exe: C:\SFML-1.6\lib\sfml-system-dll: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

Can someone clearly explain to me what to do EXACTLY?
Pages: 12