1

I'm new here, so hello world!

I'm working on a big project in C++. I'm using Visual Studio 2015 Ultimate RC.

I got 2 projects in same solution:

MyProgram and MyProgram.Input It is something like that:

Mouse.h in MyProgram.Input:

#include "SDL.h"

class Mouse
{
public:
    int x, y;
    void Update();
}

Mouse::Update()
{
SDL_GetMouseState(&x, &y);
}

MyProgram.Input has included SDL2 and it compiles fine!

So I included MyProgram.Input to MyProgram. MyProgram is console application, when I include "Mouse.h" to MyProgram and compile it I got this error: Cannot find include file: "SDL.h"

I want to get mouse input from MyProgram.Input in my console in MyProgram project.

SDL.h is file from MyProgram.Input, not from MyProgram!

2
  • 1
    Looks like you need to tell the MyProgram application the location of the SDL.h file. Commented May 18, 2015 at 20:40
  • Could you tell me how? Commented May 18, 2015 at 20:41

2 Answers 2

3

You can't refer to .h include by project but by path on drive. You need to create a common folder for all includes of you projects, move you current .h to it and all new .h will be added to it, this must has a relation to the solution path and go to the project that you need to include file from this folder and open its properties and add include directory that is something like $(SolutionDir)\Includes , where Includes is the directory to include .h files. Now you can include it in multiple projects, we use this way.

Alternative way is to use real path like

#include "../MyProgram.Input/SDL.h"
Sign up to request clarification or add additional context in comments.

Comments

2

Go to MyProgram's properties, choose C/C++ and at "Additional Include Directories" set it (or add to it) the path from MyProgram.Input where SDL.h is located. (you should use relative paths).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.