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

Author Topic: CodeBlocks 12.11 SFML 2.0  (Read 19570 times)

0 Members and 2 Guests are viewing this topic.

Niikhawod

  • Newbie
  • *
  • Posts: 7
    • View Profile
CodeBlocks 12.11 SFML 2.0
« on: February 15, 2013, 10:46:18 pm »
Hi,

I want to use sfml 2.0 with codeblocks 12.11 i have Cmake'd sfml from github and rebuild it in codeblocks, but i still get an error when i compile the basic program found in the first sfml 2.0 tutorial.

edit: i am using windows 7.
code i used.
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

Error i get.
Code: [Select]
G:\SFML\SFML-Base\main.cpp|5|undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKSsjRKNS_15ContextSettingsE'|
« Last Edit: February 16, 2013, 12:31:10 am by Niikhawod »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: CodeBlocks 12.11 SFML 2.0
« Reply #1 on: February 15, 2013, 11:40:54 pm »
How are you linking SFML? Dynamic/static? debug/release? :)

Also please make use of the code=cpp tags, when posting code.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Niikhawod

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CodeBlocks 12.11 SFML 2.0
« Reply #2 on: February 15, 2013, 11:53:14 pm »
How are you linking SFML? Dynamic/static? debug/release? :)

Also please make use of the code=cpp tags, when posting code.

i am linking dynamic libs and i am using release libs.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: CodeBlocks 12.11 SFML 2.0
« Reply #3 on: February 16, 2013, 12:07:09 am »
Then make sure that you're project settings are also set to release.

You can't mix debug and release modes!
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Niikhawod

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CodeBlocks 12.11 SFML 2.0
« Reply #4 on: February 16, 2013, 12:30:42 am »
that made it worse  :-\

obj\Debug\main.o||In function `main':|
G:\SFML\SFML-Base\main.cpp|5|undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKSsjRKNS_15ContextSettingsE'
|
G:\SFML\SFML-Base\main.cpp|6|undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'|
G:\SFML\SFML-Base\main.cpp|7|undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
|
G:\SFML\SFML-Base\main.cpp|15|undefined reference to `_imp___ZN2sf6Window5closeEv'|
G:\SFML\SFML-Base\main.cpp|12|undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
|
G:\SFML\SFML-Base\main.cpp|18|undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'|
G:\SFML\SFML-Base\main.cpp|19|undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
|
G:\SFML\SFML-Base\main.cpp|19|undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'|
G:\SFML\SFML-Base\main.cpp|20|undefined reference to `_imp___ZN2sf6Window7displayEv'
|
G:\SFML\SFML-Base\main.cpp|9|undefined reference to `_imp___ZNK2sf6Window6isOpenEv'|
obj\Debug\main.o||In function `ZN2sf11CircleShapeD1Ev'
:|
G:\SFML\SFML-Base\..\..\..\SFML-2.0-REBUILD\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
G:\SFML\SFML-Base\..\..\..\SFML-2.0-REBUILD\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `_imp___ZTVN2sf11CircleShapeE'
|
G:\SFML\SFML-Base\..\..\..\SFML-2.0-REBUILD\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `_imp___ZN2sf5ShapeD2Ev'|
||=== Build finished: 13 errors, 0 warnings (0 minutes, 0 seconds) ===|


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: CodeBlocks 12.11 SFML 2.0
« Reply #5 on: February 16, 2013, 12:44:43 am »
Make sure you link the libraries in the correct order.
You can remember it like this, sfml-graphics depends on sfml-window depends on sfml-system; so the order should be:

sfml-graphics
sfml-window
sfml-system
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Niikhawod

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CodeBlocks 12.11 SFML 2.0
« Reply #6 on: February 16, 2013, 01:00:02 am »
I have setup everythjing like in the tutorial but for some reason it is not working anymore.

i have previosly compiled sfml 2.0 and that one worked but have stupidly deleted that one and now it doesn't work anymore :/.

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: CodeBlocks 12.11 SFML 2.0
« Reply #7 on: February 17, 2013, 02:02:51 am »
Did you include everything(anything important*) in SFML's lib folder**- Under Linker settings?
Then include SFML's Include folder -under Search Directories under Compiler
Then do the same for SFML's lib folder -Under Linker(Next to Compiler)
Want me to post some pictures to help?

*You need Window,System,Graphics,Audio and maybe Network(If you want it)
**People Frown on this but it work for me... You don't have to do the SFML_STATIC OR DYNAMIC under #defines
If you notice I put "....", in my sentences way too much... I'm sorry.

Niikhawod

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CodeBlocks 12.11 SFML 2.0
« Reply #8 on: February 17, 2013, 02:50:06 pm »
i recompiled sfml and nog i am getting a different error when i compile and want to run the test program.

error i now get


linker


linker settings


compiler


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: CodeBlocks 12.11 SFML 2.0
« Reply #9 on: February 17, 2013, 03:38:14 pm »
How exactly did you compile SFML?
Make sure your compiler is setup correctly in Code::Blocks.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Niikhawod

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CodeBlocks 12.11 SFML 2.0
« Reply #10 on: February 17, 2013, 04:08:59 pm »
i am using the default gnu gcc compiler settings in code::blocks.

Edit: i have recompiled sfml with a saperate MinGW32 - TDM compiler and now it is working again.  :-\
« Last Edit: February 17, 2013, 04:20:58 pm by Niikhawod »

Daddi

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://foxdev.de/
    • Email
Re: CodeBlocks 12.11 SFML 2.0
« Reply #11 on: February 20, 2013, 06:04:53 pm »
You could also download mingw from the official website and overrite Code::Blocks mingw folder. There are some differences between the compilers of each version.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: CodeBlocks 12.11 SFML 2.0
« Reply #12 on: February 20, 2013, 06:14:57 pm »
You could also download mingw from the official website and overrite Code::Blocks mingw folder.
Or rather download the Code::Blocks version without MinGW and set the compiler manually. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

JoshuaBehrens

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: CodeBlocks 12.11 SFML 2.0
« Reply #13 on: February 22, 2013, 05:39:25 pm »
Can you please post more precisely what you did to make it work? I wanted to move from my XP to my new 7 machine and I have the same error. I also followed the hint to have the right order. Didnt helped. Using the static libraries gives more undefined references. A question on stackoverflow couldn't helped me.
« Last Edit: February 22, 2013, 06:05:06 pm by JoshuaBehrens »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: CodeBlocks 12.11 SFML 2.0
« Reply #14 on: February 23, 2013, 11:29:35 am »
Maybe your installation is broken, but without specifc details it's impossible to tell
Just follow the official tutorial 1:1.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything