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

Author Topic: SFML 2.1 Visual Studio Tutorial not working  (Read 8727 times)

0 Members and 3 Guests are viewing this topic.

timothy.wright.software

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
SFML 2.1 Visual Studio Tutorial not working
« on: August 07, 2014, 05:48:57 am »
Tried the Visual Studio tutorial, but no luck.

Output from the console:

1>------ Build started: Project: vs_test, Configuration: Debug Win32 ------
1>HelloSFML.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::String::String(char const *,class std::locale const &)" (??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>sfml-window-s-d.lib(Window.cpp.obj) : error LNK2001: unresolved external symbol "public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B)
1>sfml-window-s-d.lib(Window.cpp.obj) : error LNK2019: unresolved external symbol "public: __thiscall sf::Clock::Clock(void)" (??0Clock@sf@@QAE@XZ) referenced in function "public: __thiscall sf::Window::Window(void)" (??0Window@sf@@QAE@XZ)
1>sfml-window-s-d.lib(JoystickImpl.cpp.obj) : error LNK2001: unresolved external symbol "public: __thiscall sf::Clock::Clock(void)" (??0Clock@sf@@QAE@XZ)
1>sfml-graphics-s-d.lib(ImageLoader.cpp.obj) : error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sf::err(void)" (?err@sf@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ) referenced in function "int __cdecl parse_png_file(struct png *,int,int)" (?parse_png_file@@YAHPAUpng@@HH@Z)
1>sfml-graphics-s-d.lib(Image.cpp.obj) : error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sf::err(void)" (?err@sf@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ)
1>sfml-graphics-s-d.lib(GLCheck.cpp.obj) : error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sf::err(void)" (?err@sf@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ)
1>sfml-graphics-s-d.lib(Shader.cpp.obj) : error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sf::err(void)" (?err@sf@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ)
1>sfml-graphics-s-d.lib(Texture.cpp.obj) : error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sf::err(void)" (?err@sf@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ)
1>sfml-window-s-d.lib(Window.cpp.obj) : error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sf::err(void)" (?err@sf@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ)

.. bunch more stuff...

I've been programming for a long time, and I did triple check that I have the correct version of SFML for Visual Studio 10, have the include folder and lib folder defined in the project, added the

sfml-main-d.lib
sfml-window-s-d.lib
sfml-graphics-s-d.lib

static libraries (in that order), and added the SFML_STATIC pre-processor macro.

Still doesn't work, but I'm not sure. 

metsuro

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #1 on: August 07, 2014, 06:23:31 am »
Isn't it graphics window system for the includes as graphics relies on window and system? so wouldn't you also need to add in the system link? Also thanks to Ixrec in another thread I had a similiar issue and he linked me this. https://github.com/SFML/SFML/wiki/FAQ#build-link-static
« Last Edit: August 07, 2014, 06:25:03 am by metsuro »

timothy.wright.software

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #2 on: August 07, 2014, 02:58:22 pm »
I added the sfml-system-s-d.lib but that didn't fix the problem.

This error is new to me:

warning LNK4099: PDB 'sfml-main-d.pdb' was not found with 'sfml-main-d.lib(SFML_Main.cpp.obj)'

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #3 on: August 07, 2014, 03:12:42 pm »
I think the order should be graphics, then window, then system.

This is what I would add in debug configuration linker:
sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;

and this in release:
sfml-graphics.lib;sfml-window.lib;sfml-system.lib;

I'm not sure where sfml-main would fit into this order as I've never used it.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

timothy.wright.software

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #4 on: August 07, 2014, 03:13:34 pm »
OK.  It is working.  These are my static libraries:

sfml-system-s-d.lib
sfml-graphics-s-d.lib
sfml-window-s-d.lib
sfml-main-d.lib

If you add the libraries following the tutorial they would be in this order:

sfml-graphics-s-d.lib
sfml-window-s-d.lib
sfml-system-s-d.lib
sfml-main-d.lib

It was only by luck that I figured out that the system library needs to be first or the program won't link correctly.  That seems like an important point that should be added to the tutorial. 

I tried moving the libraries around, but could only get it to break if the system library isn't first.  Not a big deal but I couldn't figure out if there are any other orders that break it.

« Last Edit: August 07, 2014, 03:17:28 pm by timothy.wright.software »

timothy.wright.software

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #5 on: August 07, 2014, 03:16:39 pm »
I doubled checked the order.  At least on my machine, Windows 7, Visual Studio 2010, the library order you posted doesn't seem to work.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #6 on: August 07, 2014, 03:27:15 pm »
If it requires the system library first, it could be that it needs them in the reverse order i.e. system, window, graphics. Could this be due to linking statically? Different compilers link in opposite orders but I don't know why your VS2010 would link differently to VS2014.
Also, don't you need to link the other stuff that is in the FAQ about Statically Linking?

EDIT: realised that I got your version wrong here.
« Last Edit: August 07, 2014, 05:30:51 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

timothy.wright.software

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #7 on: August 07, 2014, 04:27:44 pm »
This was just the simple example code from the tutorial, which only uses the libraries I linked to draw a green circle.  I can't comment on the order other than if I move the system library it no longer links.


Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #8 on: August 07, 2014, 05:25:23 pm »
I just tried this example. It's the first time I've ever attempted to statically link anything. *cheers*

However, following what you did, I got the same errors. The way to fix it is to link all of the dependencies listed in the FAQ (that has been linked here twice now). If it's under the heading of the module you are using, you'll need to link it. For example, you'll need to link glew, freetype etc. to be able to use the graphics module.

I think that the tutorial should mention this or, at the very least, link to the FAQ about it.

One more thing, don't forget to add .lib to the dependencies.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #9 on: August 07, 2014, 07:03:55 pm »
Quote
I think that the tutorial should mention this
The tutorials for SFML 2.2 will mention it, since this doesn't apply to previous versions.
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #10 on: August 07, 2014, 07:16:24 pm »
Righty-ho. Apologies.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

MadMartin

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #11 on: August 07, 2014, 11:35:11 pm »
warning LNK4099: PDB 'sfml-main-d.pdb' was not found with 'sfml-main-d.lib(SFML_Main.cpp.obj)'
BTW: This is clearly no error. Instead, it's a warning for your debug build that the debug symbols can't be found. Won't be there in release, though.

timothy.wright.software

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: SFML 2.1 Visual Studio Tutorial not working
« Reply #12 on: August 09, 2014, 04:57:10 pm »
I did verify that if I statically link all libraries, then their order doesn't matter.  Which is a lot easier because I only have to cover it once.

 

anything