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

Author Topic: Static SFML unresolved external symbol  (Read 3529 times)

0 Members and 1 Guest are viewing this topic.

EvilDuck

  • Newbie
  • *
  • Posts: 5
    • View Profile
Static SFML unresolved external symbol
« on: January 19, 2019, 03:11:34 am »
I'm trying to get a statically linked copy of SFML working through CMake, but even though I'm pretty sure I've linked everything correctly (Images down the bottom if you want to double-check), I keep getting a bunch of unresolved external symbol errors. If it helps, I think it may be connected to ws2_32.lib, as removing the file from the additional libraries doesn't seem to do anything.

This section will have my system specifications, as recommended by the forum. I am running a 64-bit windows 10 system with an i7-7700 CPU, a 1070 GPU and  16GB of RAM. I am on the latest version of Visual Studio and got the latest Visual Studio release of SFML. I also used CMake 3.13.3 to create the project.

Here is the test code:

#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(500, 500), "New Window", sf::Style::Close);
       
        while (window.isOpen())
        {
                sf::Event windowEvent;
                window.pollEvent(windowEvent);
                if (windowEvent.type == sf::Event::Closed) window.close();
        }

        return 0;
}
 

And here is the output:

1>------ Build started: Project: Static SFML, Configuration: Release Win32 ------
1>Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27026.1 for x86
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>
1>cl /c /ID:\SFML\include /Zi /W3 /WX- /diagnostics:classic /sdl /O2 /Oi /Oy- /GL /D SFML_STATIC /D WIN32 /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /MT /GS /Gy /fp:precise /permissive- /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Release\\" /Fd"Release\vc141.pdb" /Gd /TP /analyze- /FC /errorReport:prompt "Static SFML.cpp"
1>
1>Static SFML.cpp
1>sfml-window-s.lib(VideoModeImpl.obj) : error LNK2001: unresolved external symbol __imp__EnumDisplaySettingsW@12
1>sfml-window-s.lib(CursorImpl.obj) : error LNK2001: unresolved external symbol __imp__GetDC@4
1>sfml-window-s.lib(WglContext.obj) : error LNK2001: unresolved external symbol __imp__GetDC@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__GetDC@4
1>sfml-window-s.lib(CursorImpl.obj) : error LNK2001: unresolved external symbol __imp__ReleaseDC@8
1>sfml-window-s.lib(WglContext.obj) : error LNK2001: unresolved external symbol __imp__ReleaseDC@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__ReleaseDC@8
1>sfml-window-s.lib(CursorImpl.obj) : error LNK2001: unresolved external symbol __imp__LoadCursorW@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__LoadCursorW@8
1>sfml-window-s.lib(CursorImpl.obj) : error LNK2001: unresolved external symbol __imp__DestroyCursor@4
1>sfml-window-s.lib(CursorImpl.obj) : error LNK2001: unresolved external symbol __imp__CreateIconIndirect@4
1>sfml-window-s.lib(CursorImpl.obj) : error LNK2001: unresolved external symbol __imp__CopyIcon@4
1>sfml-window-s.lib(WglContext.obj) : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
1>sfml-window-s.lib(WglContext.obj) : error LNK2001: unresolved external symbol __imp__DestroyWindow@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__DestroyWindow@4
1>sfml-window-s.lib(WglContext.obj) : error LNK2001: unresolved external symbol __imp__ShowWindow@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__ShowWindow@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__TrackMouseEvent@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__TranslateMessage@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__DispatchMessageW@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__PeekMessageW@20
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__SendMessageW@16
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__RegisterDeviceNotificationW@12
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__DefWindowProcW@16
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__CallWindowProcW@20
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__RegisterClassW@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__UnregisterClassW@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__CreateWindowExW@48
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__FlashWindowEx@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__SetWindowPos@28
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__GetKeyState@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__MapVirtualKeyW@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__GetCapture@0
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__SetCapture@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__ReleaseCapture@0
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__GetForegroundWindow@0
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__SetForegroundWindow@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__SetWindowTextW@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__GetClientRect@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__GetWindowRect@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__AdjustWindowRect@12
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__ShowCursor@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__SetCursor@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__ScreenToClient@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__MapWindowPoints@16
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__ClipCursor@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__GetWindowLongW@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__SetWindowLongW@12
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__GetWindowThreadProcessId@8
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__CreateIcon@28
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__DestroyIcon@4
1>sfml-window-s.lib(WindowImplWin32.obj) : error LNK2001: unresolved external symbol __imp__ChangeDisplaySettingsW@8
1>sfml-window-s.lib(JoystickImpl.obj) : error LNK2001: unresolved external symbol __imp__RegCloseKey@4
1>sfml-window-s.lib(JoystickImpl.obj) : error LNK2001: unresolved external symbol __imp__RegOpenKeyExW@20
1>sfml-window-s.lib(JoystickImpl.obj) : error LNK2001: unresolved external symbol __imp__RegQueryValueExW@24
1>C:\Users\hhgra\source\repos\Static SFML\Release\Static SFML.exe : fatal error LNK1120: 48 unresolved externals
1>Done building project "Static SFML.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 

I think I included images of everything I changed in the Properties, but if you want to know anything else just tell me.

EvilDuck

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Static SFML unresolved external symbol
« Reply #1 on: January 19, 2019, 03:40:33 am »
I fixed it by making a new project and changing the properties in that. Whatever was wrong with the first one must have been something I might have changed without realising and never thought to check.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Static SFML unresolved external symbol
« Reply #2 on: January 19, 2019, 01:41:44 pm »
This doesn't affect the linking but your event loop should be a while loop and pollEvent doesn't always return an event so your code is now sometimes accessing an uninitialized sf::Event structure. You should also add clear and display to your main while loop. And your GPU and RAM amount also wouldn't effect the linking ;D , I wonder what it was though.
Back to C++ gamedev with SFML in May 2023

 

anything