Bug: 'C++ Compile Failed'. I Cannot create a C++ project

For some buggy reason I cannot open Visual Studio 2017 through UE4 4.16. I have tried now numerous times and get a ‘failed to compile’ error message every time. I can do nothing in C++ in 4.16. Can someone tell me what going on here?

Successfully added class
‘NewCameraComponent’, however you must
recompile the ‘Udemy_BuildingEscape’
module before it will appear in the
Content Browser. Failed to
automatically compile the
‘Udemy_BuildingEscape’ module.

Would you like to open the Output Log
to see more details?

I would like to add that I have this same problem in 4.15 as well.

Close the Editor, Open Visual Studio with your project, hit ctrl + f5.

Let me know if it helped! <3

No it did not work. It said it could not be compiled. Possibly UE4 4.16 is not compatible with VS2017.

It told me to rebuild manually, which is beyond my skill.

Can you exactly tell what you are doing, because I thought you were adding another C++ class in Unreal called “NewCameraComponent”. Did you then try to compile and this message appeared?
I’m assuming all this, because I had such a message once myself.

The compile bug exists in both the C++ project creation wizard and the BP creation wizard. The top comment refers to the BP project I was fiddling with. Whether trying to create a C++ Project or trying to access Visual Studio 2017 functionality in a BP Project, I get the same ‘C++ Compile Failed’ message. The connection between Visual Studio 2017 and Unreal Engine 4 versions 4.15 and 4.16 has a bug that causes this compile failure.

No it did not work → It told me to rebuild manually, which is beyond my skill.

… you sure you Build it from VS Studio? Because thats what manually rebuild means. Asside from that VS2017 is fully compatible with 4.16.

There is no Skill needed just open your .sln file. Use the Hotkey Ninjin mentioned or rightclick YourProject inside VS and choose Build. Let it Compile and it will tell you afterwards if it succeeded or failed.

If it failed for some reason look at the Output Window it will tell you why it could not Compile. If you cant solve it on your own upload your log as .txt here or any site like pastebin.com (dont post the whole thing as Comment pls its hard to read otherwise) we help you out.

Thanks, but UE4 4.15 and 4.16 should just auto load up VS2017, but it is not doing that, its broken.

I know others have reported this bug. Are they fixing it?

This is the message I get when trying to create a project in the UE4 C++ project creation wizard/browser

The project could not be compiled. Would you like to open it in Visual Studio?

Running C:/Program Files/Epic Games/UE_4.16/Engine/Binaries/DotNET /UnrealBuildTool.exe

CppProjectTest Development Win64

-project=“C:/Unreal Projects/CppProjectTest/CppProjectTest.uproject”
-editorrecompile -progress -NoHotReloadFromIDE Performing full C++ include scan (building a new target) Creating makefile for CppProjectTest (no existing makefile) @progress push 5% Parsing headers for CppProjectTestEditor

Running UnrealHeaderTool “C:\Unreal Projects\CppProjectTest\CppProjectTest.uproject”
“C:\Unreal Projects\CppProjectTest\Intermediate\Build\Win64\CppProjectTestEditor\Development\CppProjectTestEditor.uhtmanifest”

-LogCmds=“loginit warning, logexit warning, logdatabase error”

-Unattended -WarningsAsErrors -installed Reflection code generated for CppProjectTestEditor in 6.9986518 seconds @progress pop Performing 8 actions (4 in parallel) [2/8] Resource ModuleVersionResource.rc.inl [3/8] Resource
PCLaunch.rc SharedPCH.Engine.cpp
CppProjectTest.cpp
CppProjectTestGameModeBase.cpp
CppProjectTest.generated.cpp
[7/8] Link UE4Editor-CppProjectTest.dll
[8/8] Link UE4Editor-CppProjectTest.lib LINK : fatal error LNK1181: cannot open input file ‘ws2_32.lib’

Creating library C:\Unreal Projects\CppProjectTest\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-CppProjectTest.lib
and object C:\Unreal Projects\CppProjectTest\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-CppProjectTest.exp

ERROR: UBT ERROR: Failed to produce item: C:\Unreal Projects\CppProjectTest\Binaries\Win64\UE4Editor-CppProjectTest.dll

Total build time: 43.72 seconds (Local executor: 0.00 seconds)

This is message I get trying to rebuild the broken default startup project in VS2017

**1>------ Build started: Project: CppProjectTest, Configuration: Development_Editor x64 ------

1>Performing 1 actions (4 in parallel)

1>[1/1] Link UE4Editor-CppProjectTest.dll

1>LINK : fatal error LNK1181: cannot open input file ‘ws2_32.lib’

1>ERROR : UBT error : Failed to produce item: C:\Unreal
Projects\CppProjectTest\Binaries\Win64\UE4Editor-CppProjectTest.dll

1>Total build time: 1.93 seconds (Local executor: 0.00 seconds)

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ““C:\Program Files\Epic Games\UE_4.16\Engine\Build\BatchFiles\Build.bat” CppProjectTestEditor Win64 Development “C:\Unreal Projects\CppProjectTest\CppProjectTest.uproject” -waitmutex” exited with code 5. Please verify that you have sufficient rights to run this command.

1>Done building project “CppProjectTest.vcxproj” – FAILED.

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========**

Also I uninstalled VS2017 then reinstalled VS2017 directly from the UE4 project creation browser in the C++ section, then attempted to create a simple default project with no starter content. The thing is just plain broke. They gotta fix it I think.

I would also like to add that I just ran a Malware scanner on my computer that detected a very nasty .ms trojan something or other that hides in the background breaking stuff, a level 4 out of 5 on the threat scale. I am obviously wondering if that could be a reason its not working.

I know other people have reported this problem, but I have not heard any body offer a solution or admit that it is a bug they need to fix.

Yeah this bug is ridiculous. I reinstalled UE4 4.16 and got the same cannot compile error. But went into VS2017 and built the solution successfully using their ‘Build’ tool and attempted to start the program with the ‘start without debugging’ tool. At this point I get a message that says,

'the following modules are missing
or built with a different engine
version:
UE4Editor-MyProjectCPPtest.dll would
you like to rebuild them now?

If I hit yes, it says, ‘cannot compile’, if I hit No it does nothing.

I think I have to go into the .uproject files or something and disable some modules that were not installed properly in this version or something or other. Can someone help me with that?

Bump. I am pretty confident the problem is that some modules need to be disabled somewhere or other. Can someone help me out with this?

can't create and compile new C++ project - C++ - Epic Developer Community Forums

Quote Originally Posted by Zeblote
View Post

You’re probably missing some

VS components. Open the installer
again and make sure these are enabled:

  • Desktop development with .NET
  • Desktop development with C++
  • Game development with C++

The windows 8.1 sdk also needs to be
enabled under individual components.


This is the correct answer. After following your instruction C++ projects for UE4 4.16 loaded up perfectly and double clicking C++ classes in UE4 caused VS2017 to load the code just as it should.

However oddly enough I had previously had literally everything VS had to offer installed, for no good reasons, and did not work. I Uninstalled all that unnecessary stuff and reinstalled with only the needed stuff, and it worked.

It says it cant open ws2_32.lib thats the Windows Socket Library. So either something blocks the Access (Sockets are something Anti Virus/Malware definitly looks out for)

Or something is missing on your System. Win 8.1 SDK, CPP Runtime, .NET stuff etc you got to double check that and if in doubt reinstall. Especially Win 8.1 SDK!

This guide might help you also but thats no gurantee that everything got installed correctly!

Haha exactly my last comment 4 minutes before you posted the Answer :stuck_out_tongue_winking_eye:

Ok, it came back… This time it says license is invalid. What do you thing that means? below is not the full error message.


The project could not be compiled. Would you like to open it in Visual Studio?

Distributing 8 actions to XGE
--------------------Build System Warning---------------------------------------
License is invalid:
License information is invalid. Please try reloading your license file using the Coordinator Monitor application on the Coordinator machine, or reinstall IncrediBuild.
This build will run in standalone mode.


--------------------Project: Default-------------------------------------------
(0:20.51 at +0:00)
SharedPCH.Engine.cpp
(0:00.23 at +0:20)
UDemy_BuildingEscape.cpp
(0:00.26 at +0:20)
UDemy_BuildingEscapeGameModeBase.cpp
(0:00.34 at +0:21)
UDemy_BuildingEscape.generated.cpp
ModuleVersionResource.rc.inl (0:00.56 at +0:21)
PCLaunch.rc (0:00.09 at +0:21)
UE4Editor-UDemy_BuildingEscape.dll (0:00.14 at +0:22)
LINK : fatal error LNK1181: cannot open input file ‘ws2_32.lib’

Error executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe (tool returned code: 1181)
---------------------- Done ----------------------

Rebuild All: 0 succeeded, 1 failed, 0 skipped

**1 build system warning(s):

  • License is invalid**

ERROR: UBT ERROR: Failed to produce item: C:\Unreal Projects\UDemy_BuildingEscape\Binaries\Win64\UE4Editor-UDemy_BuildingEscape.dll
Total build time: 51.51 seconds (XGE executor: 0.00 seconds)


Thats because Incredibuild is Paid software deinstall the extension :stuck_out_tongue_winking_eye: or disable it somehow inside VS. I don´t use Incredi Build so can´t help you there.

Ok, the Incredibuild stuff is gone now, but now it says it ‘Failed to produce item’ . It worked one time after following aforesaid instruction, then this again :frowning:

The project could not be compiled. Would you like to open it in Visual Studio?

Running C:/Program Files/Epic Games/UE_4.16/Engine/Binaries/DotNET/UnrealBuildTool.exe Udemy_EscapeBuilding Development Win64 -project=“C:/Unreal Projects/Udemy_EscapeBuilding/Udemy_EscapeBuilding.uproject” -editorrecompile -progress -NoHotReloadFromIDE
Performing full C++ include scan (building a new target)
Creating makefile for Udemy_EscapeBuilding (no existing makefile)
@progress push 5%
Parsing headers for Udemy_EscapeBuildingEditor
Running UnrealHeaderTool “C:\Unreal Projects\Udemy_EscapeBuilding\Udemy_EscapeBuilding.uproject” "C:\Unreal Projects\Udemy_EscapeBuilding\Intermediate\Build\Win64\Udemy_EscapeBuildingEditor\Development

\Udemy_EscapeBuildingEditor.uhtmanifest" -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -installed
Reflection code generated for Udemy_EscapeBuildingEditor in 5.6123431 seconds

@progress pop
Performing 8 actions (4 in parallel)
[2/8] Resource ModuleVersionResource.rc.inl
[3/8] Resource PCLaunch.rc
SharedPCH.Engine.cpp
Udemy_EscapeBuilding.cpp
Udemy_EscapeBuilding.generated.cpp
Udemy_EscapeBuildingGameModeBase.cpp
[7/8] Link UE4Editor-Udemy_EscapeBuilding.dll
[8/8] Link UE4Editor-Udemy_EscapeBuilding.lib
LINK : fatal error LNK1181: cannot open input file 'ws2_32.lib’
Creating library C:\Unreal Projects\Udemy_EscapeBuilding\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Udemy_EscapeBuilding.lib and object C:\Unreal Projects\Udemy_EscapeBuilding\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Udemy_EscapeBuilding.exp
ERROR: UBT ERROR: Failed to produce item: C:\Unreal Projects\Udemy_EscapeBuilding\Binaries\Win64\UE4Editor-Udemy_EscapeBuilding.dll
Total build time: 12.67 seconds (Local executor: 0.00 seconds)

Can you build from VS and upload the whole Outputlog as .txt or upload on www.pastebin.com please?

Also please reinstall by Hand: