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

Author Topic: What project do i create?  (Read 3465 times)

0 Members and 2 Guests are viewing this topic.

Syntactic Fructose

  • Jr. Member
  • **
  • Posts: 80
  • Overflowing stacks and eating snacks
    • View Profile
What project do i create?
« on: March 07, 2012, 01:42:12 am »
Im lost, if i want to create a simple window in SFML, do i use a console project? or a SFML project? or what?! I use code blocks currently and have had a hellish day trying to install SFML to work properly, im constantly getting errors with the SFML project wizard in code blocks and the only answer ive been able to get was to stop using the wizard... So what project do i use? Will console work? Heres the extremely simple code i cant get to work(using a console project atm).
Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

int main(int argc, char** argv)
{
    bool running = true;
   sf::Window App(sf::VideoMode(1200, 600, 32), "SFML WINDOW");
   while(running)
   {
       App.Display();
   }
   return EXIT_SUCCESS;
}

Mjonir

  • Full Member
  • ***
  • Posts: 142
    • View Profile
What project do i create?
« Reply #1 on: March 07, 2012, 02:15:53 am »
I suggest you start from scratch and follow http://www.sfml-dev.org/tutorials/1.6/start-cb.php to the letter. I also had quite a few problems setting up everything when I picked up SFML, but trust me this tutorial works perfectly for SFML1.6. It might me a bit confusing at first, but once you get the hang of it and actually understand what each option mean, it's really simple :)

As for your question, do not use "SFML project". The best choice to begin with is "console application", this is also what the tutorial recommends.

Blue Protoman

  • Newbie
  • *
  • Posts: 4
    • View Profile
What project do i create?
« Reply #2 on: March 07, 2012, 03:25:56 am »
Really?  I use SFML project, and it works just fine for me.  I leave the console on, though, so I can have output for debugging purposes.

Syntactic Fructose

  • Jr. Member
  • **
  • Posts: 80
  • Overflowing stacks and eating snacks
    • View Profile
What project do i create?
« Reply #3 on: March 07, 2012, 03:30:23 am »
Thanks for the help, its almost completely working now, only one last problem currently. I get this error:
Code: [Select]
ld.exe||cannot find -lsfml-audio.dll|
||=== Build finished: 1 errors, 0 warnings ===|

when running this code:
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    // Create the main window
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");

    // Load a sprite to display
    sf::Image Image;
    if (!Image.LoadFromFile("cb.bmp"))
        return EXIT_FAILURE;
    sf::Sprite Sprite(Image);

// Start the game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear screen
        App.Clear();

        // Draw the sprite
        App.Draw(Sprite);

        // Update the window
        App.Display();
    }

    return EXIT_SUCCESS;
}


I think it has to do with something the tutorial said in these two quotes:
Quote
Your program should now compile, link and run fine. If you linked against the dynamic versions of the SFML libraries, donc forget to copy the corresponding DLLs (sfml-system.dll in this case) to your executable's directory, or to a directory contained in the PATH environment variable.

and
Quote
If you are using the Audio package, you must also copy the DLLs of the external libraries needed by it, which are libsndfile-1.dll, and OpenAL32.dll.
These files can be found in the extlibs\bin directory of the package that you downloaded (SDK or development files).

Help is appreciated, thank you. ALSO: this code was created through the codeblocks SFML wizard.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
What project do i create?
« Reply #4 on: March 07, 2012, 07:57:13 am »
This is not a runtime error, it's a linker error. Your linker options are wrong, you must link to import libraries (.a) not to DLLs.
Look carefully at the corresponding screenshot and explanation in the tutorial.
Laurent Gomila - SFML developer

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
What project do i create?
« Reply #5 on: March 11, 2012, 11:30:02 pm »
I think I need to sig these so I don't have to go looking for them anytime someone needs them.

In Code Blocks your linked libs should look something like these just be sure to drop the [] from the name since they aren't part of it and change in and out the -s and -d depending on what you need.

libsfml-graphics[-s][-d].a
libsfml-window[-s][-d].a
libsfml-audio[-s][-d].a
libsfml-network[-s][-d].a
libsfml-system[-s][-d].a

In Visual Studio they should look something like these:

sfml-graphics[-s][-d].lib
sfml-audio[-s][-d].lib
sfml-window[-s][-d].lib
sfml-system[-s][-d].lib
sfml-network[-s][-d].lib

Hope this helps. :)
I've got SFML2 working for Code::Blocks but I'm still working on issues with Visual Studio and haven't figured it out yet. :) :(
I have many ideas but need the help of others to find way to make use of them.