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

Author Topic: Visual Studio 2010 Express Problems [SOLVED]  (Read 9540 times)

0 Members and 1 Guest are viewing this topic.

AngelHoof

  • Newbie
  • *
  • Posts: 27
    • View Profile
Visual Studio 2010 Express Problems [SOLVED]
« on: June 29, 2011, 01:48:20 pm »
Hiya...

So, once again I've attempted to get SFML to work, with no real success.

I run this code:

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
   
    // Start 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 the screen (fill it with black color)
        App.Clear();

        // Display window contents on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


And get this in my output:
Code: [Select]
1>------ Build started: Project: SFMLFixThisShit, Configuration: Release Win32 ------
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@QAEXXZ)
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: bool __thiscall sf::Window::GetEvent(class sf::Event &)" (?GetEvent@Window@sf@@QAE_NAAVEvent@2@@Z)
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: bool __thiscall sf::Window::IsOpened(void)const " (?IsOpened@Window@sf@@QBE_NXZ)
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: void __thiscall sf::Window::Close(void)" (?Close@Window@sf@@QAEXXZ)
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z)
1>C:\Users\Ante\Documents\Visual Studio 2010\Projects\SFMLFixThisShit\Release\SFMLFixThisShit.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


It's configured for release, I have Linker->Input = sfml-graphics.lib, in the VC++ Directories I have the Include folder and lib folder from the VC++ install directories added in, whereas the SFML files are.

What did I miss? I'm going crazy here.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Visual Studio 2010 Express Problems [SOLVED]
« Reply #1 on: June 29, 2011, 01:54:38 pm »
Link all the SFML libraries you are using, also sfml-window and sfml-system (and sfml-main for a normal main() function).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

AngelHoof

  • Newbie
  • *
  • Posts: 27
    • View Profile
Visual Studio 2010 Express Problems [SOLVED]
« Reply #2 on: June 29, 2011, 02:19:27 pm »
Aha... I thought I only needed to link graphics since that's the only one i'm using in ze code, am I wrong?

Anyway, a console window pops up and then the .exe just stops working (standard windows "has stopped working" popup).

Xander314

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://sfmlcoder.wordpress.com/
    • Email
Visual Studio 2010 Express Problems [SOLVED]
« Reply #3 on: June 30, 2011, 10:55:29 am »
Quote
I thought I only needed to link graphics since that's the only one i'm using in ze code, am I wrong?

You only need to link what you're using. However, graphics functionality relies on window and system functionality (the <sfml/graphics.hpp> header includes <sfml/window.hpp> and <sfml/system.hpp> implicitly).

As for your crash, did you build the binaries yourself? (I'm guessing not, as you're using SFML 1.6). I suggest getting SFML 2.0 and building the binaries yourself. That will avoid any inconsistencies due to mismatched compiler versions. Building the binaries may seem daunting if you've not done that kind of thing before, but for me it solved a lot of other problems.

Laurent's Tutorial
If you want a complete step by step list of instructions, you could also try my tutorial.

AngelHoof

  • Newbie
  • *
  • Posts: 27
    • View Profile
Visual Studio 2010 Express Problems [SOLVED]
« Reply #4 on: June 30, 2011, 12:31:48 pm »
Quote from: "Xander314"
Quote
I thought I only needed to link graphics since that's the only one i'm using in ze code, am I wrong?

You only need to link what you're using. However, graphics functionality relies on window and system functionality (the <sfml/graphics.hpp> header includes <sfml/window.hpp> and <sfml/system.hpp> implicitly).

As for your crash, did you build the binaries yourself? (I'm guessing not, as you're using SFML 1.6). I suggest getting SFML 2.0 and building the binaries yourself. That will avoid any inconsistencies due to mismatched compiler versions. Building the binaries may seem daunting if you've not done that kind of thing before, but for me it solved a lot of other problems.

Laurent's Tutorial
If you want a complete step by step list of instructions, you could also try my tutorial.


Ohai Xander, I do seem to recall you being on the C++ Forums, no? ;)

Thanks for the links, I'll check this out!

Xander314

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://sfmlcoder.wordpress.com/
    • Email
Visual Studio 2010 Express Problems [SOLVED]
« Reply #5 on: June 30, 2011, 12:46:13 pm »
Yep. :) Not to be confused with xander333 or xander337 ;)

AngelHoof

  • Newbie
  • *
  • Posts: 27
    • View Profile
Visual Studio 2010 Express Problems [SOLVED]
« Reply #6 on: June 30, 2011, 12:59:23 pm »
Tried your tutorial, I get this error when i run the "cmake -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=Release" etc code:

"CMake error: Could not create named generator Nmake Makefiles"

Any ideas?

Xander314

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://sfmlcoder.wordpress.com/
    • Email
Visual Studio 2010 Express Problems [SOLVED]
« Reply #7 on: June 30, 2011, 01:09:29 pm »
If you error was exactly this:
Quote
"CMake error: Could not create named generator Nmake Makefiles"

then make sure you've got your capitalisation correct: "NMake Namefiles"

AngelHoof

  • Newbie
  • *
  • Posts: 27
    • View Profile
Visual Studio 2010 Express Problems [SOLVED]
« Reply #8 on: June 30, 2011, 03:00:19 pm »
Damnit!  I had written True/False instead of TRUE/FALSE :(

Omg... Everything seems to have built fine, you are a god my friend, a GOD.

Now to go through your First SFML project tutorial!  :D

Xander314

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://sfmlcoder.wordpress.com/
    • Email
Visual Studio 2010 Express Problems [SOLVED]
« Reply #9 on: June 30, 2011, 05:13:32 pm »
Just to clarify, I wouldn't watch the first project video tutorial as it has a few mistakes (I'm meaning to re-upload it, but I'm hampered by slow internet). However, the textual version is up to date.

EDIT: If you have any questions about it, post there or here, PM me or email me or whatever. I welcome all input on my tutorials :)

AngelHoof

  • Newbie
  • *
  • Posts: 27
    • View Profile
Visual Studio 2010 Express Problems [SOLVED]
« Reply #10 on: June 30, 2011, 05:55:36 pm »
One thing I would love is an indepth but easy to understand explanation as to the differences about release/debug and static/dynamic and the scenarios in which either should be applied  :)

Xander314

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://sfmlcoder.wordpress.com/
    • Email
Visual Studio 2010 Express Problems [SOLVED]
« Reply #11 on: June 30, 2011, 06:39:24 pm »
That would be nice. At a simple level I don't think it's too bad, though. When your developing, use debug configuration because it has debugging information in it (e.g. I think there are different C runtimes for debug and release) and use release to distribute because it's compiler optimised and smaller.

The details of how DLLs are implemented are extremely complex. Personally, I use the DLL libraries where possible, but the sf::Text/sf::Font error has sometimes driven me to use the static libraries.

AngelHoof

  • Newbie
  • *
  • Posts: 27
    • View Profile
Visual Studio 2010 Express Problems [SOLVED]
« Reply #12 on: June 30, 2011, 11:58:39 pm »
Ah, so Debug it is then :3

I can't wrap my head around how static enables development without the DLLs :s

Xander314

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://sfmlcoder.wordpress.com/
    • Email
Visual Studio 2010 Express Problems [SOLVED]
« Reply #13 on: July 01, 2011, 09:20:07 am »
Well because static libraries have all the implementation inside them. Then the C++ linker links them to your project at link time, that is it merges the executable code from your own translation units (compiled source files) with the executable code from the static libraries. You program then contains all the SFML binary code so why should it need DLLs? ;)

AngelHoof

  • Newbie
  • *
  • Posts: 27
    • View Profile
Visual Studio 2010 Express Problems [SOLVED]
« Reply #14 on: July 01, 2011, 01:26:45 pm »
Ah, excellent. But then why don't we use static libraries all the time?

Size, compiler time, licketylicketyboomboom?

 

anything