"Cannot open source file tank.h"

Ok… I think this may be related to how I created my first C++ class for the project… I didn’t check Public or Private (because I did it for the challenge) for the PlayerTankController.h/cpp class… Then, I checked Public when I created my Tank.h/cpp… now… NOBODY can read the tank.h file. Even tank.cpp throws a “Cannot open source file tank.h”, let alone when I try to add Tank and class ATank to the PlayerTankController…

I’m using Unreal 4.15.1 and VS Community 2017. Any suggestions?

2 Likes

Ok… this is probably not the “ideal” solution… but for now, I changed the include headers… Because PlayerTankController.h is in Source/BattleTank, and Tank.h is in Source/BattleTank/Private I changed the include to for PlayerTankController to read:

#include "../BattleTank/Public/Tank.h"

and the include for Tank.cpp to read:

#include "../Public/Tank.h"

I’m almost positive this is NOT the intended method (especially since Intellisense will only guide you through the paths if you use a backslash, but the compiler rejects backslashes insisting that you use forward slashes.) But, it works, and I was able to carry on the lesson (only lost… 90 minutes)

1 Like

And… after much experimentation, the solution has been found… Not sure why this isn’t done automatically when you select Public, but here’s what I finally did… (In Visual Studio)

On the top menu bar Project|BattleTank Properties (it will be on the very bottom of the Project tab).
That will open a window, find the section marked "VC++ Directories…
That will show a list of different categories of directories… Under Include, click the tiny down arrow and you’ll get an option “Build”…
Once in Build, click the icon that looks like a Folder with an asterisk in it… that will take you to a browser where you can locate the BattleTank/Source/Public directory. Once it’s added to the include, the problem goes away completely.

7 Likes

Hi Brian all am getting is 2 options for the include Directories can you plz help

Try clicking Edit.

Thank you. This was very helpful. To anyone who is still wondering, it looks like clicking Edit on the drop-down works just as well. I didn’t see the build option–perhaps it was taken out in a newer version of VS.

thank you your remark was helpful for me
I have two projects. In first when I created C++ files its automatically directed Public folder
but in second I don’t know what change .ccp file can’t find .h file :slight_smile: and then I apply to your instructions

Privacy & Terms