Search code examples
c++visual-studiolinkersdl-2

Made a VS project using SDL2. It used to work but now I'm getting linker issues


At first it says that it couldn't open the files like "SDL.h not found", even though I included all the libraries and all that. So I switched it all over to x86 which fixed all of those problems but now I'm getting a linker issue saying that onecore.lib is not found. I read every tutorial I can find on how to adjust the project settings and include all the libraries. I can't find the onecore.lib file anywhere in the onecore folder of the Visual Studio program files.

Searched in every folder of 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\lib\onecore' and found no such file that VS is looking for. No idea what to do. I also included SDL2 path in the environment variables.


Solution

  • Copy and pasting file paths to your include folders and libraries caused the file paths to have the "\" slash. Visual Studio expects the "/" slash. This subtlety caused all my issues and making that small change fixed everything. For some reason, people still suggest copy and pasting the file paths even though this issue can arise. As far as I can tell, I'm the only person that has run into this issue. Nearly every tutorial suggests copy and pasting file paths and none of them mention that the slash can cause issues. Very difficult to diagnose if you don't know because the file paths are correct and it's easy to assume that copying the path is good enough.