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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MrHri

Pages: [1]
1
I was not aware of that, I just downloaded codeBlocks without paying attention because I had a new computer, sorry.
Anyway I noticed something surprising in my code (nothing to do with SFML). I actually put variables as size for my 2D array (instead of the constants of my simplified example). I used to program in C so that seemed normal to me, but apparently runtime-sized arrays are not a thing in C++. The CodeBlocks compiler (either version) doesn't seem to be aware of that, everything works and I didn't even get a warning!

2
Downgraded Code::Blocks to v.16 and it solved the issue. It felt wrong though :D
Seriously, could someone at least add a warning of some sort in the tutorial ? It would have saved me quite a lot of time

3
General / Linking problem when I try to load a font (wrong GCC version ?)
« on: February 01, 2018, 09:12:34 pm »
Hello,

I am new to SFML so I followed the tutorial steps to get familiar with it. Everything worked fine, until I tried to display text and got the following error:
Quote
undefined reference to `_imp___ZN2sf4Font12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'

The thing is, I am using Code::Blocks and I think the problem comes down to that. As I said, I followed very precisely the tutorial and the first issue I encountered was choosing which SFML version to download: the tutorial says "check which of the libgcc_s_sjlj-1.dll or libgcc_s_dw2-1.dll files is present in your MinGW/bin folder", but both of them are present!

I downloaded the DW2 one and got a bunch of "undefined references" so I uninstalled it and went with the SJLJ one. Once again, I configured my project exactly as the tutorial said (for dynamic libraries) and this time, the code compiled and worked fine. I thought i was done with the GCC version thing until I tried to display text and got the aforementioned error. I checked the GCC version used by CodeBlocks and it's 5.1, when the SFML SJLJ package available to download is compiled with GCC 4.9.2.

So i have 3 questions:
1) Is there a chance the error comes from something else? (knowing that the other functions work fine and I followed the tutorial instructions)
2) If not, it seems like the only reason a TDM/SJLJ version is downloadable is because Codeblocks uses this compiler. So, why not change it when Codeblocks moves to a newer version of GCC?
3) The simplest way to solve this is to compile SFML myself using cmake, right ?


Here is a simplified version of my code:
    #include <SFML/Graphics.hpp>
    #include <iostream>

    using namespace sf;

    void example(){
        // This first part worked well
        RenderWindow window(VideoMode(800, 600), "My Window");
        RectangleShape walls[10][10];

        window.clear();
        for(unsigned int i=0;i<10;i++){
            for(unsigned int j=0;j<10;j++){
                walls[j]=RectangleShape(Vector2f(8,8));
                walls[j].setPosition(16*j,16*i);
                walls[j].setFillColor(Color::White);
                window.draw(walls[j]);
            }
        }
        window.display();

        Font MyFont;
        if (!MyFont.loadFromFile("..\resources\arial.ttf")){       // The error occurs here
            std::cout<<"Error"<<std::endl;
        }
        Text text;
        text.setFont(MyFont);
    }

Pages: [1]