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

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.

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.

Well, i am going to keep bumping this Bug till I get a good answer. But I can’t wait around, I am just going to have to go back to an earlier version.

I already have ‘Windows SDK 8.1’ installed in my VS2017 components list, as you can see in the list above where I listed all my installed components.

Not strictly C++ related, but I’ve just wasted a heap of time trying to
track down why the Generate Project
Files command is silently failing for
some of my 4.16 projects. Turns out
it’s because of dependencies on
plugins that are not yet installed for
4.16 (which makes sense and was the case with previous versions too) but
changes to UBT in 4.16 seem to have
resulted in the error dialog not being
shown, so you just get a silent
failure.

So, for anyone experiencing the same
issue, remember that the likely cause
is plugin references inside your
.uproject file. If you disable them
there until the 4.16 plugin is
available, you should be able to
generate the project files.

This is a quote from someone, Possibly you can help me out with this? This may be the problem.

UE4 4.16.2 the newest version does not fix this Bug, below is the error report:

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 WorkorNoWork Development Win64 -project=“C:/Unreal Projects/WorkorNoWork/WorkorNoWork.uproject” -editorrecompile -progress -NoHotReloadFromIDE

Performing full C++ include scan (building a new target)

Creating makefile for WorkorNoWork (no existing makefile)

@progress push 5%

Parsing headers for WorkorNoWorkEditor
Running UnrealHeaderTool “C:\Unreal Projects*WorkorNoWork**WorkorNoWork*.uproject” “C:\Unreal Projects*WorkorNoWork*\Intermediate\Build\Win64**WorkorNoWorkEditor\Development**WorkorNoWorkEditor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -installed

Reflection code generated for WorkorNoWorkEditor in 6.3863317 seconds
@progress pop

Performing 8 actions (4 in parallel)

[2/8] Resource ModuleVersionResource.rc.inl

[3/8] Resource PCLaunch.rc

SharedPCH.Engine.cpp

WorkorNoWork.cpp

WorkorNoWork.generated.cpp

WorkorNoWorkGameModeBase.cpp

[7/8] Link UE4Editor-WorkorNoWork.dll

[8/8] Link UE4Editor-WorkorNoWork.lib

LINK : fatal error LNK1181: cannot open input file 'ws2_32.lib’

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

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

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

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

In the key line the problem is something related to ‘ws2_32.lib’.

MyProjectSTuff.dll [8/8] Link
UE4Editor-MyProjectSTuff.lib LINK :
fatal error LNK1181: cannot open input
file ‘ws2_32.lib’

Still does not work.

I switched to an older version of UE4 (v. 4.10.4), which uses VS2015 (I installed using the default setup). C++ projects do not work in this version either. Here is error Message. The “LINK : fatal error LNK1181: cannot open input file ‘ws2_32.lib’” Message is gone, but I cannot create C++ projects in the UE4 4.10.4 either.

SEE PASTEBIN:

https://pastebin.com/xPKC441C

Your solution to delete or move the BuildConfiguration.xml file may have worked, but when I uninstalled and attempted to reinstall VS2017 (to get a clean and minimal install, save 8-10GB) I get this message. Know what is up with that?

This looks like the same issue I had
here where Tigan2 suggested to move
(move instead of delete in case
something goes wrong) the
BuildConfiguration.xml file out of
“C:\Users\User\Documents\Unreal
Engine\UnrealBuildTool”, which worked
for me as well.

deleting the BuildConfiguration.XML file did cause Unreal Engine 4.16.2 to load up a C++ project for me the way it is supposed to (both the Unreal Engine Editor and Visual Studio loading up together), But only one time.

I could not repeat this success. The XML file regenerates and the compile failure returns.

This is the second time now that I have gotten the thing to load up once correctly, then subsequently fail.

Also Visual Studio 2015 Community is not available for download anymore at visualstudio.com. I get the message:

Download Results Sorry, we couldn’t
find any downloads for you.

Ok, I don’t know what else to do so I used my Glary Utilities clean up tools package to ‘clean’ everything up in my computer, just hit it with everything. Whatever it did, it did fix the install problem so VS2017 installed correctly through the ‘UE4 project creation browser’. This method of install automatically selects necessary components, ‘Windows SDK 8.1’, ‘Unreal Engine Installer’, ‘Visual Studio C++ Core…’ etc… So everything needed is there, But I still get the same ‘Compile Failure’ error message and the UE4 Engine Editor will not load.

Deleting the BuildConfiguration.xml file in UE4 4.16 (searching through File Explorer) did work once, but only once. The file regenerates every time, the compile error subsequently returns and projects fail to compile and the UE4 Engine Editor will not load up.

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.

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?