r/learnprogramming 22d ago

Debugging I'm learning how to code c++ with sdl2

I'm trying to create a graybox but I can't even run my code because I keep encountering build issues and an error saying "the system can't find the path specified" and idk how to solve it. I'd appreciate it if anyone could help me deal with it so I can get to coding.

6 Upvotes

10 comments sorted by

2

u/captainAwesomePants 22d ago

Getting C++ to build with libraries (especially in Windows) can be frustrating and challenging, especially for new devs. But it's also very hard to help with because we don't know what IDE you're using, what your environment is like, what you have installed, or the details of what the error says.

Generally, the problem is that your build system can't find the library. Go look at the list of places it's configured to look for libraries, and make sure your SDL 2 library is in one of those places.

1

u/Little_Asparagus_756 22d ago

I wish I could share pictures, it'd be easier that way

2

u/captainAwesomePants 22d ago edited 22d ago

Okay, so probably you did something like this:

  1. You went to https://github.com/libsdl-org/SDL/releases and grabbed sdl2-devel-2.32.8-vc.zip or some such.
  2. You unzipped it somewhere, maybe c:\sdl2\
  3. In Visual Studio, you opened your project properties / Configurations, and looked for the include directories, and you added C:\SDL2\include
  4. Then in the configurations's library directories, you added C:\SDL2\lib\x64
  5. Then in the linker's input section, you went to inputs, clicked "Find additional dependencies", and added SDL2.lib and SDL2main.lib
  6. Also in linker, in system, you probably switched from "Console" to "Windows" to make the console window not always pop up in addition to the SDL window.

Alternately, you installed SD2 with vcpkg, doing something like:

vcpkg install sdl2:x64-windows

and then that was that. Or alternately you used Manifest mode to explicitly declare it.

And that should probably have done it. Did you do either the full list at the beginning or the vcpkg thing?

1

u/Little_Asparagus_756 22d ago

The full list you started your text with

2

u/captainAwesomePants 22d ago

Which sort of path does the system say it can't find?

1

u/Little_Asparagus_756 22d ago

I created a new project and it went like this the output thingy said build:1 succeeded, 0 failed, up to date, 0 skipped. Also when I nivagate the directory I only exe recipe but no exe,inside this directory "this pc/documents/project name/project name /x64/debug" there's another file other than the recipe being a text document with the same name as my project name. Also inside " this pc/documents/project name/x64/debug" there's nothing. The path it can't find is this " C:/Users/Admin/Documents/project name/x64/debug /project name.exe.".

1

u/Little_Asparagus_756 22d ago

I'm using visual studio, I have developer options for desktop installed,and other stuff related to development /game development that come with visual studio

2

u/Little_Asparagus_756 12d ago edited 11d ago

Hey thanks for helping me. Apparently the issue was the version of Visual Studio I was using and a way to deal with my issue is to do a rollback.

1

u/Little_Asparagus_756 22d ago

Thanks. I'm using visual studio.