[Visual studio] Cannot open source files, but code compiles and runs fine

Hi I am still new to both Visual Studio and Unreal Engine4 so this may just be something trivial that I have missed, I am not even sure if this is a VS problem or UE problem to be honest, any help / clues would be appreciated…

Recently I started a project just for experiment and things from the Top Down template, created a few classes to test things with then I found the need to better organize my codes. Previously all my header and cpp files just scatter in the Source/ProjectName folder (the default behaviour) so as the very first step I began to re-arrange my header and cpp files into Public and Private sub folders as read in other threads in the forum.

Now after some struggle I have got the project to compile successfully and runs same as before the re-arrangement. However, all my includes in the cpp files are highlighted with the Cannot open source file error in Visual Studio and so the whole file are red under-lined (autocomplete also stops functioning as a result).

Strange enough, if in the cpp files I change #Include ProjectName.h to #Include Public/ProjectName.h, all errors and highlights are gone except for constructors, they are still highlighted (autocomplete still does not work except for general syntax keywords).

Does anyone know what went wrong / what steps I missed?

I think I have found the solution as the problem has vanished (hope I have truly solved it) by following the answer in this link Cannot compile - "delayimp.lib" not found - Programming & Scripting - Unreal Engine Forums

i.e. under Project -> Properties -> Configuration Properties -> VC++ Directorys -> Library Directories
enter $(LibraryPath)

5 Likes

It’s over 5 and a half years later, but just wanted to say thank you. This led me to solving my issue as well

In case it helps anyone: My issue differs a bit as I have a separate project using with UE but had the same symptoms with compiling successfully yet having all those in-editor include issues. Fortunately, I just had to add the new project directory to the Include Directories (instead of Library Directories) and IntelliSense worked perfectly fine after updating!