I was having issues in Visual Studio Code on my Linux (Ubuntu 20.04) with Include errors that were showing on my BullCowGame Unreal 4.22 project along with auto-complete not working properly. I managed to solve the issue and decided to write a post about it to hopefully help somebody in the future to save some time for them or point them in the right direction.
I followed the lecture and initially added the Windows defines.txt to my c_cpp_properties.json which didn’t resolve the issue; then I added the defines_mac.txt which resolved the auto-complete issues but didn’t resolve the Include errors that I was getting. Specifically the errors were regarding the following message:
cannot open source file ...
After some time I managed to resolve this issue with the following steps.
- Opened Unreal Engine
- Clicked on New Project
- Clicked on the C++ tab
- Selected the Basic Code option and created the project
- It will open Visual Studio Code with some Basic C++ Unreal Engine Code
- Navigated to:
.vscode/c_cpp_properties.json
- Copied the defines field and pasted it into my other project (BullCowGame)
- Replaced the
UE_PROJECT_NAME
value with my project name (BullCowGame) - Replace
MYPROJECT4_API
with my project name (BULLCOWGAME_API) - Navigated to
BullCowCartridge.cpp
and saw the include error still - Hover over the error which mentioned that a specific file
Cartridge.generated.h
could not be opened - Searched for the file in visual studio code and located it in my project folder
- Added its path to
includePath
withinc_cpp_properties.json
- The error was gone
- Make sure to refresh the project in Unreal engine editor to make sure it picks up the changes
- Compile the the project to make sure everything is fine
Hopefully this will help somebody with a similar issue to mine.