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

Author Topic: Visual Studio 2013 - Linking Problem  (Read 4909 times)

0 Members and 1 Guest are viewing this topic.

Xornand

  • Jr. Member
  • **
  • Posts: 78
  • C++ / Python
    • View Profile
Visual Studio 2013 - Linking Problem
« on: December 19, 2013, 11:42:10 am »
Hello. I'm trying to build my project in Visual Studio 2013, however it throws linking errors, such as:

1>sfml-window-s.lib(WglContext.obj) : error LNK2001: unresolved external symbol __imp__wglMakeCurrent@8
1>sfml-window-s.lib(WglContext.obj) : error LNK2001: unresolved external symbol __imp__wglShareLists@8
1>sfml-window-s.lib(JoystickImpl.obj) : error LNK2001: unresolved external symbol __imp__joyGetPosEx@8
1>sfml-window-s.lib(JoystickImpl.obj) : error LNK2001: unresolved external symbol __imp__joyGetDevCapsW@12
1>sfml-system-s.lib(SleepImpl.obj) : error LNK2001: unresolved external symbol __imp__timeGetDevCaps@8
1>sfml-system-s.lib(SleepImpl.obj) : error LNK2001: unresolved external symbol __imp__timeBeginPeriod@4
1>sfml-system-s.lib(SleepImpl.obj) : error LNK2001: unresolved external symbol __imp__timeEndPeriod@4
And there's more.

I'm trying to link against the static libraries I built myself from the source code from the GitHub repository. Here's a short list of steps I followed:

And in my project:
  • Copied all header (include) files to an appropriate folder.
  • Copied all .lib files to an appropriate folder.
  • Set my project to look for headers and .lib files in the appropriate folders.
  • Defined all .lib include inputs, as following: sfml-main.lib, sfml-system-s.lib, sfml-window-s.lib, sfml-graphics-s.lib, sfml-audio-s.lib, sfml-network-s.lib for the release version and debug equivalent files (with the -d postfix) for the debug version.
  • Added SFML_STATIC flag to preprocessor settings.

Am I missing something? A very similar setup worked fine on Visual Studio 2012 (with everything compiled under VC++ 11). I have no idea why it doesn't work here, any advice would be highly appreciated.
« Last Edit: December 19, 2013, 11:43:43 am by Xornand »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Visual Studio 2013 - Linking Problem
« Reply #1 on: December 19, 2013, 11:52:18 am »
The wgl... functions should be in opengl32.lib. Did you forget linking it?

The other functions are inside winmm.lib.

If you're in doubt and think an unresolved external symbol should be provided by the Windows API, just look for "MSDN <function name>" on Google. It should point you to the correct MSDN page, e.g. timeGetDevCaps. Open the page and scroll down. It will list the header to use (which isn't important here) as well as the library to link to.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Visual Studio 2013 - Linking Problem
« Reply #2 on: December 19, 2013, 11:57:01 am »
Am I missing something? A very similar setup worked fine on Visual Studio 2012 (with everything compiled under VC++ 11). I have no idea why it doesn't work here, any advice would be highly appreciated.
You're using the latest version of SFML, thus you should be aware of changes that have happened to the source and thus tutorials might not be uptodate. A few weeks ago, SFML's way of linking dependencies for static libraries was changed. You'll now how to link the dependencies in your final application yourself.

More info an the full discussion can be found here.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Xornand

  • Jr. Member
  • **
  • Posts: 78
  • C++ / Python
    • View Profile
Re: Visual Studio 2013 - Linking Problem
« Reply #3 on: December 19, 2013, 12:09:18 pm »
The wgl... functions should be in opengl32.lib. Did you forget linking it?

The other functions are inside winmm.lib.

If you're in doubt and think an unresolved external symbol should be provided by the Windows API, just look for "MSDN <function name>" on Google. It should point you to the correct MSDN page, e.g. timeGetDevCaps. Open the page and scroll down. It will list the header to use (which isn't important here) as well as the library to link to.

In fact I didn't link to those libraries. I assumed the static libraries would already contain all the dependencies. Especially the CMake options for linking dependencies were a bit misleading - it appeared to me as if everything would be included in the .lib files automatically. Anyway, thanks a lot for the info.

Am I missing something? A very similar setup worked fine on Visual Studio 2012 (with everything compiled under VC++ 11). I have no idea why it doesn't work here, any advice would be highly appreciated.
You're using the latest version of SFML, thus you should be aware of changes that have happened to the source and thus tutorials might not be uptodate. A few weeks ago, SFML's way of linking dependencies for static libraries was changed. You'll now how to link the dependencies in your final application yourself.

More info an the full discussion can be found here.

I wasn't aware of the changes. Thanks for the link.

 

anything