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

Author Topic: Difficulty in getting SFML to work (first use) with Code::Blocks/MinGW (C++)  (Read 13816 times)

0 Members and 4 Guests are viewing this topic.

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Lightning fast reply :)

I made a typi t seems. I said I did both the lib and include folders for compilers. I got the include folder for the compiler and the lib folder for the linker.

This occured to me. I tried testing it with -lsfml-xxx, etc, and I get the exact same error, except it says it with the l, etc. "lsfml-system: no such..." etc.

Speaking of using the normal inclusion of libraries, would you just include them, in order, as the DLL's or in the case of static, the static libraries?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Quote
This occured to me. I tried testing it with -lsfml-xxx, etc, and I get the exact same error, except it says it with the l, etc. "lsfml-system: no such..." etc.
If you have libsfml-xxx.a in the directory that you added to the linker search paths, and either "sfml-xxx" in Linker/Libraries or "-lsfml-xxx" in Linker/Other options, then it must work.
Laurent Gomila - SFML developer

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Ah... I had lsfml-xxx, not -lsfml-xxx. Quite sorry.

Those errors are gone. I really want to see something, eh, work. So, I thought, I can try the window example code.

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create the main window
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

    // Start main loop
    bool Running = true;
    while (Running)
    {
        App.Display();
    }

    return EXIT_SUCCESS;
}
 

The error is that Display is not a member of the Window class, of which the object App i s. However, in the help manual, (for this rc anyhow), display is listed as a member. Or, trying the random number generation example, randomizer seems to not exists.

Are these errors caused my changed names/classes or am I still doing it wrong?

THanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
This is SFML 1.6, not 2.0. Look at the doc, examples, forum, ... to find code which is compatible with SFML 2.
Laurent Gomila - SFML developer

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
So I figured. But I am not sure where to find examples, or on the forums to much, (not a simple test anyhow), and qouting the doc that came with the release canidate:

void sf::Window::display  (  ) 

Display on screen what has been rendered to the window so far.

This function is typically called after all OpenGL rendering has been done for the current frame, in order to show it on screen.


I don't know how display would not be a member, unless the doc has not been updated or something.

For some reason I cannot get the clock to work... I thought it returned a flaot but ti seems to return a time.. hrm.

What is an example code I COULD test?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Quote
I don't know how display would not be a member, unless the doc has not been updated or something.
Sorry, I don't understand what you mean.

Quote
What is an example code I COULD test?
Under /examples in the source repository on github.
But then what will you do? You should wait for the tutorials, you're obviously not experimented enough with SFML to be able to deduce the SFML 2 syntax from the 1.6 tutorials.
Laurent Gomila - SFML developer

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
The doc that comes with it. The HTML help file. It had it as Display, I thought. Mabye I misread it, because display() works.

I just wanted to start learning, eh, how to use it. I was also pretty certain that clock returned a flaot but it seemes it returns a time which then has a function for a flaot. Kind of confused...

Any idea how long itll tuturials are up?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
I'm writing the tutorials, but it takes time.

But if you really want to play with SFML 2, maybe you can use the 1.6 tutorials, apply the new naming convention, and look in the 2.0 doc or the forum (there's a topic for every major modification) for things that don't work out of the box.
Laurent Gomila - SFML developer

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
I understand. Sorry, I guess I just get frustrated a bit easily with these things.

I will try that, yes. Turns out, I did read it wrong - I wasn't exactly looking to see if it was display or Display, I was looking to see if it was or wasn't there altogether.

I don't think I have gotten any errors, yet, beyond those of incorecctly using SFML. That reminds me. Recall that "press up to close" theory I have? When run, it opens neither the console (as it is a GUI) or a window. PRessing up only does stuff with the Code::Blocks window. Is this because it was not in focus and cannot use the input?

Other than this, the clock confuses me. If I followed the doc correctly, (and degub error messages) the Clcok member getElapsedTime() returns a Time value. Time objects have a function inSeconds (I think), but using it did not seem to work. (as in, mytime.inSeconds(myclock.getElapsedTime). Either way, I am not entirely sure how to get the time at all. I feel it is more simple though. What am I missing?

I also wonder about DLL's. The only way I have gotten things to work, such as the pong example, was to place all the DLL's, say, literally right next to to it. Is there anyway it could be all in a folder somehow? Instead of all the DLL's you use.

Also, what is the difference between debug libs and.. non debug ones?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Quote
Other than this, the clock confuses me. If I followed the doc correctly, (and degub error messages) the Clcok member getElapsedTime() returns a Time value. Time objects have a function inSeconds (I think), but using it did not seem to work. (as in, mytime.inSeconds(myclock.getElapsedTime). Either way, I am not entirely sure how to get the time at all. I feel it is more simple though. What am I missing?
The doc shows how to get the time from a sf::Clock, and how to get the number of seconds or microseconds from a time value. Just apply these pieces of code without trying to do complicated things ;)

Quote
I also wonder about DLL's. The only way I have gotten things to work, such as the pong example, was to place all the DLL's, say, literally right next to to it. Is there anyway it could be all in a folder somehow? Instead of all the DLL's you use.
If you don't want to copy the DLLs in the application's directory, they must be in a directory which is in the PATH environment variable.

Quote
Also, what is the difference between debug libs and.. non debug ones?
Debug libraries have debug symbols inside and are less optimized, so that you can step into the associated source code with the debugger.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
I really feel like you're too inexperimented to use SFML, or any library. You should really learn more about all the basic stuff that's involved in getting a C++ app to run -- not just the language itself, but all the environment / compiler / linker / runtime stuff, etc.

Otherwise we'll spend days in this discussion, and you'll never learn anything because you'll just blindly apply my solutions.

No offense, I'm just trying to really help you, more than just answering all your questions one by one.
Laurent Gomila - SFML developer

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Ouch. My self esteem is dropping :)

Well, from what I can see, it returns a time value. Or... would that be an object, I think? I wasn't entirely sure how to use said object. Or, what variable to apply toSeconds to, and I was a bit confused by what memebers held the time data and how it could be used. I will look into it agaian and see if I can figure it out this time. Although the first few times I tried Iwas trying to get a float. I forgot that was SFML 1.6.

Ah. That is logical. From.. at least this and another set of external libraries I have tried, there the DLLs, the static libraries, and debug versions of each, but I never quite knew the difference.

On the DLL's... path. That term always scares me. I feel like if I tried to get it working,  - well, it wouldn't work. Sigh. Still not entirely sure what this is, either. Something involved with running something from the command line, though. Or, perhaps, compiling it from there. What I mean is, though, is there a way I could package the app and libraries but not have them all in one single folder together? Seems... odd for whatever reason.

I agree that I am not very expierienced in this area, but I do know a bit about how it works. Compilers turn the source files, let's say, into object files (I think that is .o?) The linker puts them together into an exutable. I don't know much about runtime compared to this but if I recall this is where libraries come into the mix.

Probably not a bad idea to read into it more, though.

On that note, seeing as how I am not very expierienced, where do you recommend I start? I am guessing you have a good idea of what is good to learn, and if you find it beneficial it probably is a good idea. It would be nice to know how to... well, how everything works - an dnot just how everything is seemingly handled with whatever the IDE does. Currently, though, I was just trying to see if I could make games, using C++ instead of a game engine. Throughout this process, this has been my main goal. Looking at the SFML projects sections, it seems many people share thiis interest. I don't know what other background learning one would really have on how everything works, but I am all ears if you have suggestions.
« Last Edit: April 19, 2012, 01:45:20 am by chessguy »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Quote
is there a way I could package the app and libraries but not have them all in one single folder together? Seems... odd for whatever reason.
Package them together but keep them separate? I don't get it :P

Quote
On that note, seeing as how I am not very expierienced, where do you recommend I start?
Hmm I don't know, I went through these steps a long time ago.
But consolidating your C++ and OO skills would probably be a good idea, so that you can more easily figure out things like sf::Time & sf::Clock.
Take the time to understand your development environment and tools, so that you're not stuck on every configuration error and you can focus on the relevant part -- writing code.
Laurent Gomila - SFML developer

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Well, currently, if I have any project working, it is a.exe with a bunch of DLL's next to it. Let's take most games you would download today. I don't recall ever seeing a DLL, and things are neatly inf olders. I think. Hrm. Although most of those had installers.

I was actually planning on getting better on that once I get SFML working. Not to mention, at my level I don't think I quite need virtual functions and the like yet.

On OO, I get classes - useful - and inheritance also makes sense. What I don't like as much is the public and private stuff. Like... the only way a memeber you migh tmake private would be changed is if you did something with it... never quite understodd that. I also don't quite understand how inheritance and how you inherit (Public, Private, Protected) work in regards to each other. Similarely, I don't entirely get the idea of a friend function. I guess looking back at tuturials would be a good idea, though. Got to learn it sometime.

As per the clock - to be honest, I have never seen a function that returns an object. Would you need to assign a pointer to this object or something? Still confuses me. In my mind, to use it you need to have a variable to refer to it, whcih means you must assign something to it. The only assignment I can think of is a pointer.

As per understanding the tools... I don't really know how to learn that part all that much.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Quote
Let's take most games you would download today. I don't recall ever seeing a DLL
I'm not a game player, but I thing you're wrong. Today's games use many engines composed by many modules, and those are usually dynamically linked.

Quote
As per the clock - to be honest, I have never seen a function that returns an object. Would you need to assign a pointer to this object or something? Still confuses me. In my mind, to use it you need to have a variable to refer to it, whcih means you must assign something to it. The only assignment I can think of is a pointer.
So yes, you definitely need to learn and practice more :)
The answer:
sf::Time time = clock.GetElapsedTime();
float seconds = time.asSeconds();

// or

float seconds = clock.GetElapsedTime().asSeconds();
Laurent Gomila - SFML developer

 

anything