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

Author Topic: Setting up SFML 2.1 in Visual Studio 2012 Express  (Read 3440 times)

0 Members and 1 Guest are viewing this topic.

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Setting up SFML 2.1 in Visual Studio 2012 Express
« on: October 09, 2013, 12:04:32 am »
I am having some trouble setting it up, it looks like everything is good, I entered the "sfml-graphics.lib", "sfml-window.lib" and "sfml-system.lib" stuff in the project settings but the "sfml-audio-d-2.lib" doesn't work Vs gives me this error: Error   1   error LNK1104: cannot open file 'sfml-audio-d-2.lib'

So I have to questions:
1. should I be using .lib or .dll?
The tutorial (http://www.sfml-dev.org/tutorials/2.1/start-vc.php) is showing to use .lib but I haven't done this:

The settings shown here will result in your application being linked to the dynamic version of SFML, the one that needs the DLL files. If you want to get rid of these DLLs and have SFML directly integrated to your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and "sfml-xxx-s.lib" for Release.
In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.


I thought that .dll is dynamic and .lib is static. So if I am using .lib wouldn't that mean I need that stuff ^^? I do want to be using dynamic but this is the first library I have used so I am confused as to how I set it up.

2. Why isn't the audio file working when I compile the test program? It just gives me an error and I can't run it.
« Last Edit: October 09, 2013, 12:12:08 am by nicedude80 »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Setting up SFML 2.1 in Visual Studio 2012 Express
« Reply #1 on: October 09, 2013, 12:14:26 am »
1a) .libs are what you build your program with.  Those are what Visual Studio needs to know about.  The static/dynamic debug/release stuff merely changes which .libs you need, not the fact that you need .libs.

1b) .dlls are the runtime dependencies that you distribute with a dynamically linked program executable.  In a statically linked program, these dependencies are all inside the executable, so you don't have separate files for them.  Visual Studio should never need to touch these, unless you're compiling them from source yourself.

2) At least tell us what the error was and what test program you're talking about.  We aren't psychic.
« Last Edit: October 09, 2013, 12:16:12 am by Ixrec »

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Setting up SFML 2.1 in Visual Studio 2012 Express
« Reply #2 on: October 09, 2013, 12:22:54 am »
Sorry, the error is: Error   1   error LNK1104: cannot open file 'sfml-audio-d-2.lib'

And the test program is this: (Exactly as it is here: http://www.sfml-dev.org/tutorials/2.1/start-vc.php)

#include <iostream>
#include <SFML/Graphics.hpp>

using namespace std;

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;
}

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Setting up SFML 2.1 in Visual Studio 2012 Express
« Reply #3 on: October 09, 2013, 12:32:09 am »
That's more likely to mean it can't find the file than something is wrong with the file.  Make sure that .lib is in the folder it's supposed to be (with all the others) and double check that your project settings tell VS to link to stuff in that folder (like the tutorial explains).

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Setting up SFML 2.1 in Visual Studio 2012 Express
« Reply #4 on: October 09, 2013, 12:33:33 am »
Nevermind I figured it out. I have one more question though. So you have to have the dlls in the same folder as the executable, but is there a way to move the dlls down a directory to keep it tidy? I tried but it didn't work, it couldn't find them.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Setting up SFML 2.1 in Visual Studio 2012 Express
« Reply #5 on: October 09, 2013, 12:35:45 am »
I know there are ways to control how dynamic linking takes place, but I don't think that's the kind of thing you should be looking into at your level.  If all you want is neatness, just statically link so you don't have as many .dlls in the first place.

You certainly can't move the .dlls down in any trivial way.  The closest thing would be moving the .exe and .dlls down together and making a shortcut to the .exe where it used to be.

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Setting up SFML 2.1 in Visual Studio 2012 Express
« Reply #6 on: October 09, 2013, 12:43:45 am »
Ok! Thanks for all your help!

 

anything