SFML community forums

Help => General => Topic started by: cyberstu on May 25, 2012, 06:45:28 pm

Title: SFML installation on CB
Post by: cyberstu on May 25, 2012, 06:45:28 pm
Hey all. I have recently downloaded codeblocaks and SFML. I had a load of errors to start with but that was because my project was saved as a .c file.

Now I have only 4 errors. Can I get some guidence please.

I have used the tutorial code.

#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 here are the 4 errors I get

Quote
Untitled1.o:Untitled1.cpp|| undefined reference to `sf::Clock::Clock()'|
Untitled1.o:Untitled1.cpp|| undefined reference to `sf::Clock::GetElapsedTime() const'|
Untitled1.o:Untitled1.cpp|| undefined reference to `sf::Sleep(float)'|
Untitled1.o:Untitled1.cpp|| undefined reference to `sf::Clock::GetElapsedTime() const'|
||=== Build finished: 4 errors, 0 warnings ===|

Title: Re: SFML installation on CB
Post by: Laurent on May 25, 2012, 06:50:27 pm
You must link to sfml-system, as explained in the tutorial.
Title: Re: SFML installation on CB
Post by: cyberstu on May 25, 2012, 06:57:21 pm
I have copied the files as it states. and in the linker options included

-lsfml-system
Title: Re: SFML installation on CB
Post by: Laurent on May 25, 2012, 06:58:59 pm
Can you post the contents of your .cbp file?
Title: Re: SFML installation on CB
Post by: cyberstu on May 25, 2012, 07:00:24 pm
However just looked at my CB installation and noticed the following structure

C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include

I have copied all my files to

C:\Program Files\CodeBlocks\MinGW\include

Just wondering where Im meant to copy them to
Title: Re: SFML installation on CB
Post by: cyberstu on May 25, 2012, 07:03:43 pm
heres my .cbp file

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
        <FileVersion major="1" minor="6" />
        <Project>
                <Option title="hello" />
                <Option pch_mode="2" />
                <Option compiler="gcc" />
                <Build>
                        <Target title="Debug">
                                <Option output="bin\Debug\hello" prefix_auto="1" extension_auto="1" />
                                <Option object_output="obj\Debug\" />
                                <Option type="1" />
                                <Option compiler="gcc" />
                                <Compiler>
                                        <Add option="-g" />
                                </Compiler>
                        </Target>
                        <Target title="Release">
                                <Option output="bin\Release\hello" prefix_auto="1" extension_auto="1" />
                                <Option object_output="obj\Release\" />
                                <Option type="1" />
                                <Option compiler="gcc" />
                                <Compiler>
                                        <Add option="-O2" />
                                </Compiler>
                                <Linker>
                                        <Add option="-s" />
                                </Linker>
                        </Target>
                </Build>
                <Compiler>
                        <Add option="-Wall" />
                        <Add option="-fexceptions" />
                </Compiler>
                <Unit filename="main.cpp" />
                <Extensions>
                        <code_completion />
                        <debugger />
                </Extensions>
        </Project>
</CodeBlocks_project_file>
 
Title: Re: SFML installation on CB
Post by: Laurent on May 25, 2012, 07:05:48 pm
You're not linking to anything (look, there's no "sfml-system" in this project).

Follow the tutorial carefully and everything should be ok.
Title: Re: SFML installation on CB
Post by: cyberstu on May 25, 2012, 07:14:13 pm
I have added the

-lsfml-system

to my linker settings as told on the tutorial.

I have added it to the release part, I have tried it in the other two parts as well but no luck.
Title: Re: SFML installation on CB
Post by: Laurent on May 25, 2012, 07:17:57 pm
I'm sorry, I can't help you more. The content of the project file doesn't reflect what you describe, and I don't know Code::Blocks enough to find out what you could have done wrong.
Title: Re: SFML installation on CB
Post by: cyberstu on May 25, 2012, 07:20:15 pm
No problems Im going to try VC++. Im used to that anyway.