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

Author Topic: Getting error with linker - __imp_ files are missing.  (Read 1229 times)

0 Members and 1 Guest are viewing this topic.

Lime Liquid

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Getting error with linker - __imp_ files are missing.
« on: February 08, 2023, 05:57:32 pm »
This is not my first time working with SFML, I just created new project. Linked everything correctly, even defined SFML_STATIC variable in preprocessor C++ Caterogy. I'm getting bunch errors for Release, such as:

sfml-window-s.lib(VideoModeImpl.cpp.obj) : error LNK2001: unresolved external symbol __imp_EnumDisplaySettingsW
sfml-window-s.lib(CursorImpl.cpp.obj) : error LNK2001: unresolved external symbol __imp_GetDC
sfml-window-s.lib(WglContext.cpp.obj) : error LNK2001: unresolved external symbol __imp_GetDC
sfml-window-s.lib(WindowImplWin32.cpp.obj) : error LNK2001: unresolved external symbol __imp_GetDC
sfml-window-s.lib(CursorImpl.cpp.obj) : error LNK2001: unresolved external symbol __imp_ReleaseDC
sfml-window-s.lib(WglContext.cpp.obj) : error LNK2001: unresolved external symbol __imp_ReleaseDC
sfml-window-s.lib(WindowImplWin32.cpp.obj) : error LNK2001: unresolved external symbol __imp_ReleaseDC


There are totally 50 linker errors like this.
Visual Studio 2022, C++ 14 with SFML-2.5.1

Any help?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Getting error with linker - __imp_ files are missing.
« Reply #1 on: February 09, 2023, 12:11:49 am »
As mentioned in the Getting Started tutorials, once you link SFML statically, you'll also have to specify SFML's dependencies.

See the table for which libraries are needed: https://www.sfml-dev.org/tutorials/2.5/start-vc.php

You can just add them to the linker settings without having to know their location, as the linker already knows that.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lime Liquid

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Getting error with linker - __imp_ files are missing.
« Reply #2 on: February 09, 2023, 08:38:19 am »
As mentioned in the Getting Started tutorials, once you link SFML statically, you'll also have to specify SFML's dependencies.

See the table for which libraries are needed: https://www.sfml-dev.org/tutorials/2.5/start-vc.php

You can just add them to the linker settings without having to know their location, as the linker already knows that.
I already linked everything right. I suppose that it is sfml-window-s.lib that makes those 50 errors...

I have linked in Linker - Input : opengl32.lib;winmm.lib;freetype.lib;gdi32.lib;sfml-graphics-s.lib;sfml-window-s.lib;sfml-system-s.lib

Sorry for any inconvenience,

kojack

  • Sr. Member
  • ****
  • Posts: 314
  • C++/C# game dev teacher.
    • View Profile
Re: Getting error with linker - __imp_ files are missing.
« Reply #3 on: February 09, 2023, 09:04:22 am »
The functions mentioned in the errors are all from user32.lib, you need to add it to the linker input.

Lime Liquid

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Getting error with linker - __imp_ files are missing.
« Reply #4 on: February 10, 2023, 08:59:53 am »
The functions mentioned in the errors are all from user32.lib, you need to add it to the linker input.

This still doesn't fix all of the errors. Now linker.exe exits with code 1120, and I get 3 errors:

sfml-window-s.lib(JoystickImpl.cpp.obj) : error LNK2001: unresolved external symbol __imp_RegCloseKey
sfml-window-s.lib(JoystickImpl.cpp.obj) : error LNK2001: unresolved external symbol __imp_RegOpenKeyExW
sfml-window-s.lib(JoystickImpl.cpp.obj) : error LNK2001: unresolved external symbol __imp_RegQueryValueExW


Thanks anyway for your try!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Getting error with linker - __imp_ files are missing.
« Reply #5 on: February 10, 2023, 11:02:39 am »
You shouldn't have removed the libraries that were already listed, those are the once which are now failing.

You can easily find out which ones are missing, by copy pasting the function name after imp_ into a web search engine, which will then point you to a MSDN documentation page and at the bottom of that page you'll see in which library that function exists.

For example:
Search: RegCloseKey
Result: https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
Scroll down: Library Advapi32.lib

Alternatively, you can start a new VS project, copy paste the existing libraries over or just reconfigure SFML in the new project, without removing the other libraries.
Or you can use the SFML CMake template, then you don't really have to deal with library linking at all.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything