Can't compile C++ code

Hello,

I was following this video tutorial (Vid here)

and at the part I’ve linked to when I was attempting to compile my first C++ class I got an error. It said I needed to recompile my project to see my script in the contents folder. I reopened the project and nothing appeared. Also Visual Studio didn’t open. The .h and .cpp files appeared in the source folder but that was it. At the time I had Visual Studio Community 2017 installed. After some searching I found I needed to modify my installation and add the modules for C++ for Game Developing and some others to get this working. So I modified these things but it fixed nothing. (Actually this step fixed an issue that stopped my project from starting altogether after I did the first C++ class attempt). I uninstalled VS2017 and installed an old VS2015 but this didn’t fix anything. I feel like there’s a simple fix to this problem.

Sorry I don’t have the specific error messages yet. I’ll be able to send them when I get home in a few hours.

Here’s the red/yellow error code lines in the log. There’s more since I uninstalled VS and reinstalled and it says ‘couldn’t connect to Visual Studio’ there now.

LogHttp: Warning: 0000022F1AF10880: request failed, libcurl error: 6 (Couldn’t resolve host name)

ERROR: No 32-bit compiler toolchain found in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe

LogVSAccessor: Warning: Couldn’t access Visual Studio

Compiling game modules for hot reload
Performing full C++ include scan (no include cache file)
Parsing headers for FarmhouseTestEditor
Running UnrealHeaderTool “C:\Users\User\Documents\Unreal Projects\FarmhouseTest\FarmhouseTest.uproject” “C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\Build\Win64\FarmhouseTestEditor\Development\FarmhouseTestEditor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -installed -Fail
IfGeneratedCodeChanges
ERROR: ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/MyCharacterBase.generated.h’: Changes to generated code are not allowed - conflicts written to ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/MyCharacterBase.generated.h.conflict’
Error: UnrealHeaderTool failed for target ‘FarmhouseTestEditor’ (platform: Win64, module info: C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\Build\Win64\FarmhouseTestEditor\Development\FarmhouseTestEditor.uhtmanifest, exit code: OtherCompilationError (5)).

CompilerResultsLog: ERROR: ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/MyCharacterBase.generated.h’: Changes to generated code are not allowed - conflicts written to ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/MyCharacterBase.genera
ted.h.conflict’
CompilerResultsLog: Error: UnrealHeaderTool failed for target ‘FarmhouseTestEditor’ (platform: Win64, module info: C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\Build\Win64\FarmhouseTestEditor\Development\FarmhouseTestEditor.uhtmanifest,

 LogHttp: Warning: 0000022F3205C880: request failed, libcurl error: 6 (Couldn't resolve host name)

I would right click on the .uproject file and regenerate Visual Studio project files. Then open the solution in Visual Studio and make sure you are targeting the proper environment.

This reference could help: Compiling within the editor complains about changes to generated files - Programming & Scripting - Unreal Engine Forums

Hi,
I did this and when I opened the sln it didn’t compile properly. A message read ‘one or more solution where not loaded correctly’. The output says:

C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\ProjectFiles\UE4.vcxproj : error : Project “C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\ProjectFiles\UE4.vcxproj” could not be found.

C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\ProjectFiles\FarmhouseTest.vcxproj : error : Project “C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\ProjectFiles\FarmhouseTest.vcxproj” could not be found.

Definitely something got corrupted in your project. You can try to manually cleanup your .uproject file by manually removing the dependencies on Modules and then re-add them later one by one, but it is a bit of tedious task. Or if you have a backup copy you can restart from it. Not much else comes to mind at this point.

How would I do that.
Also none of my projects can compile c++ code I always get an error. I did some digging and found that you need environment variables to have the VS2017 thing. I checked by typing environment variables into the windows search bar and saw there was a VS2014 one which I deleted. I’ve reinstalled vs2017 numerous times but nothing is added to the environment variables list. Is this relevant?

Ok try this.

Make a full BACKUP copy of your project and store it on a safe drive just in case you need to restore it.

Go into your project folder and delete the Intermediate, Saved, Build folders. In practice you delete all folders except Content, Config, Source and the .uproject file.

Right click on the .uproject file and generate the Visual Studio project files. Try now to open the SLN file and see if it compiles.

Must have removed my sln at some point as now it isn’t showing thougfh it was there yesterday and I did what you said but that didn’t work either. I think it’s to do with my VS install and the way unreal is speaking to my VS/C++ compiling things that I downloaded with VS.
Another thing one of the error codes I’ve been getting has mentioned unreal 14 not 17, is this a problem?

You should definitely cleanup your Visual Studio installation by uninstalling it and re-installing following the indications here:

Make sure you have all necessary modules for C++ development. That should fix your issue. And by the way, the SLN file should be recreated automatically for you once you select Generate Visual Studio project files, but this requires your VS installation to work properly.

Do you have C++ installed at all in your Visual Studio?

You can do it from here: http://landinghub.visualstudio.com/visual-cpp-build-tools

I’ve already done this though

I used a program to complete remove vs from my system and reinstalled. This made generating the sln work and when I opened it actually compiled successfully (though the VS screen was white and showed no open file). I opened my project and tried making a c++ class. When the code was compiling I got the following red/yellow errors .

LogVSAccessor: Warning: Couldn’t access Visual Studio
Candidate modules for hot reload:
FarmhouseTest
Launching UnrealBuildTool… [C:/Program Files/Epic Games/UE_4.17/Engine/Binaries/DotNET/UnrealBuildTool.exe FarmhouseTest -ModuleWithSuffix FarmhouseTest 3912 Win64 Development -editorrecompile -FailIfGeneratedCodeChanges -canskiplink “C:/Users/User/Documents/Unreal Projects/FarmhouseTest/FarmhouseTest.uproject” ]
Compiling game modules for hot reload
Parsing headers for FarmhouseTestEditor
Running UnrealHeaderTool “C:\Users\User\Documents\Unreal Projects\FarmhouseTest\FarmhouseTest.uproject” “C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\Build\Win64\FarmhouseTestEditor\Development\FarmhouseTestEditor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -installed -Fail
IfGeneratedCodeChanges
ERROR: ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/BaseCharacter.generated.h’: Changes to generated code are not allowed - conflicts written to ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/BaseCharacter.generated.h.conflict’
Error: UnrealHeaderTool failed for target ‘FarmhouseTestEditor’ (platform: Win64, module info: C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\Build\Win64\FarmhouseTestEditor\Development\FarmhouseTestEditor.uhtmanifest, exit code: OtherCompilationError (5)).

CompilerResultsLog: ERROR: ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/BaseCharacter.generated.h’: Changes to generated code are not allowed - conflicts written to ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/BaseCharacter.generated.
h.conflict’
CompilerResultsLog: Error: UnrealHeaderTool failed for target ‘FarmhouseTestEditor’ (platform: Win64, module info: C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\Build\Win64\FarmhouseTestEditor\Development\FarmhouseTestEditor.uhtmanifest, exit code: OtherCompilationError (5)).
LogMainFrame: MainFrame: Module compiling took 99.092 seconds

LogTemp: IPP ERROR: Could not find provision directory ‘C:\Users\User\AppData\Local/Apple Computer/MobileDevice/Provisioning Profiles/’.

LogTemp: IPP ERROR: Could not find provision directory ‘C:\Users\User\AppData\Local/Apple Computer/MobileDevice/Provisioning Profiles/’.

Compiling game modules for hot reload
Parsing headers for FarmhouseTestEditor
Running UnrealHeaderTool “C:\Users\User\Documents\Unreal Projects\FarmhouseTest\FarmhouseTest.uproject” “C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\Build\Win64\FarmhouseTestEditor\Development\FarmhouseTestEditor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -installed -Fail
IfGeneratedCodeChanges
ERROR: ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/BaseCharacter.generated.h’: Changes to generated code are not allowed - conflicts written to ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/BaseCharacter.generated.h.conflict’
Error: UnrealHeaderTool failed for target ‘FarmhouseTestEditor’ (platform: Win64, module info: C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\Build\Win64\FarmhouseTestEditor\Development\FarmhouseTestEditor.uhtmanifest, exit code: OtherCompilationError (5)).

CompilerResultsLog: ERROR: ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/BaseCharacter.generated.h’: Changes to generated code are not allowed - conflicts written to ‘C:/Users/User/Documents/Unreal Projects/FarmhouseTest/Intermediate/Build/Win64/UE4Editor/Inc/FarmhouseTest/BaseCharacter.generated.
h.conflict’
CompilerResultsLog: Error: UnrealHeaderTool failed for target ‘FarmhouseTestEditor’ (platform: Win64, module info: C:\Users\User\Documents\Unreal Projects\FarmhouseTest\Intermediate\Build\Win64\FarmhouseTestEditor\Development\FarmhouseTestEditor.uhtmanifest, exit code: OtherCompilationError (5)).
LogMainFrame: MainFrame: Module compiling took 56.286 seconds

Forgot to say that the opened sln file in c++ hadn’t greyed the solutions platform bar, it now shows win64 instead of a greyed out box. Though my created classes have it greyed still and don’t show in the project .