Visual Studio Not Recognizing #include for SDL?

Started by
7 comments, last by Ovicior 8 years, 9 months ago

Hey,

So I have been working in NetBeans for a while, making a space shooter game. I recently tried to transfer it to Visual Studio.

Here's what I did:

I made a new project for the game, and proceeded to make a main.cpp and the class files, etc. After this, I copied + pasted the corresponding code into the copies. They code all recognized the #includes for eachother, but not for SDL, which I find odd.

Here's the GitHub repository

Here's the VS project download

Would really appreciate it if someone could make the needed corrections an re-upload it, but I understand if you want to nudge me in the right direction instead.

What will you make?
Advertisement

There are settings in Visual Studio to tell it where to find additional include and library files. You need to add the SDL include directory to the set of include directories and the SDL lib directory to the set of library directories.

Where you find those options depends on what version of Visual Studio you are using.

It could be Tools->Options->Projects and Solutions->VC++ Directories for older versions. For newer versions see http://www.curlybrace.com/words/2012/12/17/setting-global-c-include-paths-in-visual-studio-2012-and-2011-and-2010/ for a quick how-to.

Are you sure you added the additional includes correctly to link it to your visual studio version? This and this should help you if those weren't set correctly. As well you may need to adjust your additional library directories as necessary if you are having SDL linker problems. These can be found by right clicking the project, going to properties, and are listed under C/C++. The linker is basically the same process and can be found online as well :)

Are you sure you added the additional includes correctly to link it to your visual studio version? This and this should help you if those weren't set correctly. As well you may need to adjust your additional library directories as necessary if you are having SDL linker problems. These can be found by right clicking the project, going to properties, and are listed under C/C++. The linker is basically the same process and can be found online as well smile.png

There are settings in Visual Studio to tell it where to find additional include and library files. You need to add the SDL include directory to the set of include directories and the SDL lib directory to the set of library directories.

Where you find those options depends on what version of Visual Studio you are using.

It could be Tools->Options->Projects and Solutions->VC++ Directories for older versions. For newer versions see http://www.curlybrace.com/words/2012/12/17/setting-global-c-include-paths-in-visual-studio-2012-and-2011-and-2010/ for a quick how-to.

It still doesn't recognize the SDL files. Here's a screenshot of the project's VC++ Directories: http://gyazo.com/d393ce695ec0c711abf4081a02e4b460

Project's linker (Didn't edit this): http://gyazo.com/920520c4614049b76d0c5d9b1af18c85

What will you make?

And do you also have the correct build type selected? From the screenshots we can see that your have the include directories configured for x86/Win32/debug builds, but if your build configuration is different you need to make sure you have those configured correctly as well.

throw table_exception("(? ???)? ? ???");

In the includes in your source files, you also have "SDL2/" in the path name, but for you the files of SDL are directly placed in the include folder that you added to your vc++ directories. Visual Studio thinks it needs to search this file: "[...]SDL2-2.0.3/include/SDL2/SDL.h" which indeed doesn't exist. Removing the "SDL2/" part should fix the errors about VS not being able to locate SDL.

2 sidenotes:

1. I would use the solution dir macro to use a relative path to libraries and includes, rather than the absolute path you use now. For example: $(SolutionDir)Space Warriors\SDL2-2.0.3\include

2. I'm fairly certain you also need the libraries individually to the additional (library) dependencies, so when you edit the additional dependencies, it should something like this:

SDL2.lib
SDL2main.lib
SDL2test.lib

Hey guys, issue was resolved.

What will you make?


Hey guys, issue was resolved.

How?

Posting your solution might help others :)

Hello to all my stalkers.


Hey guys, issue was resolved.

How?

Posting your solution might help others smile.png

For some reason, all the includes were #include <SDL2/SDL.h>

Odd considering I hadn't modified the code before my computer got refreshed, and it had worked fine.

But I changed it to SDL.h

Also, in SDL, winapifamily.h has an error, so you need to download a new platform file (As of version 2.0.3). Here's the SDL development stuff that I fixed.

The fix is included in the next version (Not out as of now)

You can do it yourself with this

What will you make?

This topic is closed to new replies.

Advertisement