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

Author Topic: [SOLVED]Linker error with VS 2019  (Read 2156 times)

0 Members and 1 Guest are viewing this topic.

jpena50

  • Newbie
  • *
  • Posts: 2
    • View Profile
[SOLVED]Linker error with VS 2019
« on: May 14, 2020, 02:58:12 am »
Hi all,

I am trying to compile and build SFML 2.5.1 on Windows 10 and include it with a VS project to brush up on my skills. I am having trouble trying to track down why I am getting this linker error in visual studio. I believe I have compiled and built the source code properly using cmake and visual studio. I have added the libraries to the Linker>Input>Additional Dependencies project properties. I have added the include directory under VC++ Directories>Include Directories project properties. I have added the library directory under VC++>Library Directories project properties.
*edit: Maybe it has to do with the dynamic libraries instead of the static ones? Or does it have to do with not linking the libraries and includes in the c++ and linker project properties versus the VC++ properties?
As I'm investigating I'm thinking it has to do with the DLL's, but I could be on the wrong trail.
Any help would be much appreciated.
Quote
1>------ Build started: Project: sfmltest, Configuration: Debug x64 ------
1>Build started 5/13/2020 6:51:43 PM.
1>Target InitializeBuildStatus:
1>  Touching "x64\Debug\sfmltest.tlog\unsuccessfulbuild".
1>Target ClCompile:
1>  All outputs are up-to-date.
1>  sfml_app.cpp
1>Target Link:
1>  Searching libraries
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-audio-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-graphics-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-main-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-network-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-system-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-window-d.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\kernel32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\user32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\gdi32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\winspool.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\comdlg32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\advapi32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\shell32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\ole32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\oleaut32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\uuid.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\odbc32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\odbccp32.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\msvcprtd.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\MSVCRTD.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\OLDNAMES.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\vcruntimed.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64\ucrtd.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-audio-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-graphics-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-main-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-network-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-system-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-window-d.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\kernel32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\user32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\gdi32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\winspool.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\comdlg32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\advapi32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\shell32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\ole32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\oleaut32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\uuid.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\odbc32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\odbccp32.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\msvcprtd.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\MSVCRTD.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\OLDNAMES.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\vcruntimed.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64\ucrtd.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-audio-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-graphics-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-main-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-network-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-system-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-window-d.lib:
1>
1>  Finished searching libraries
1>
1>  Searching libraries
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-audio-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-graphics-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-main-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-network-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-system-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-window-d.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\kernel32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\user32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\gdi32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\winspool.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\comdlg32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\advapi32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\shell32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\ole32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\oleaut32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\uuid.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\odbc32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\odbccp32.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\msvcprtd.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\MSVCRTD.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\OLDNAMES.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\vcruntimed.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64\ucrtd.lib:
1>
1>  Finished searching libraries
1>
1>  Searching libraries
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-audio-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-graphics-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-main-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-network-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-system-d.lib:
1>      Searching C:\Users\Javier\Downloads\Programs\sfml-build64\lib\Debug\sfml-window-d.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\kernel32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\user32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\gdi32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\winspool.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\comdlg32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\advapi32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\shell32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\ole32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\oleaut32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\uuid.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\odbc32.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\odbccp32.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\msvcprtd.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\MSVCRTD.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\OLDNAMES.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64\vcruntimed.lib:
1>      Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64\ucrtd.lib:
1>
1>  Finished searching libraries
1>  sfml_app.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>  sfml_app.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B)
1>  C:\Users\Javier\Development\sfmltest\x64\Debug\sfmltest.exe : fatal error LNK1120: 2 unresolved externals
1>Done building target "Link" in project "sfmltest.vcxproj" -- FAILED.
1>
1>Done building project "sfmltest.vcxproj" -- FAILED.
1>
1>Build FAILED.
1>
1>sfml_app.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>sfml_app.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B)
1>C:\Users\Javier\Development\sfmltest\x64\Debug\sfmltest.exe : fatal error LNK1120: 2 unresolved externals
1>    0 Warning(s)
1>    3 Error(s)
1>
1>Time Elapsed 00:00:01.09
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
« Last Edit: May 14, 2020, 06:37:45 pm by jpena50 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Linker error with VS 2019
« Reply #1 on: May 14, 2020, 09:30:06 am »
Make sure that you define the SFML_STATIC macro in your project settings when linking to static SFML libraries, and not when linking to dynamic SFML libraries.
Laurent Gomila - SFML developer

jpena50

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Linker error with VS 2019
« Reply #2 on: May 14, 2020, 05:38:27 pm »
Thank you I've been going crazy trying to understand this error. After looking into that it seems that SFML_STATIC was defined even though I don't remember ever setting it. Everything builds successfully now. Thank you again. For those that may encounter something similar check this on Visual Studio 2019.
Project>Properties>C/C++>Preprocessor>Preprocessor definitions and delete SFML_STATIC
« Last Edit: May 16, 2020, 08:20:07 am by jpena50 »