Linux - Unreal Visual Studio Code Include Errors Solved

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.

  1. Opened Unreal Engine
  2. Clicked on New Project
  3. Clicked on the C++ tab
  4. Selected the Basic Code option and created the project
  5. It will open Visual Studio Code with some Basic C++ Unreal Engine Code
  6. Navigated to: .vscode/c_cpp_properties.json
  7. Copied the defines field and pasted it into my other project (BullCowGame)
  8. Replaced the UE_PROJECT_NAME value with my project name (BullCowGame)
  9. Replace MYPROJECT4_API with my project name (BULLCOWGAME_API)
  10. Navigated to BullCowCartridge.cpp and saw the include error still
  11. Hover over the error which mentioned that a specific file Cartridge.generated.h could not be opened
  12. Searched for the file in visual studio code and located it in my project folder
  13. Added its path to includePath within c_cpp_properties.json
  14. The error was gone
  15. Make sure to refresh the project in Unreal engine editor to make sure it picks up the changes
  16. Compile the the project to make sure everything is fine

Hopefully this will help somebody with a similar issue to mine.

Of Course! Lot of people are having this issue! :wink:

Privacy & Terms