# Cannot compile unreal engine 4 c++ project with vistual studio 2017

**URL:** <https://forums.unrealengine.com/t/cannot-compile-unreal-engine-4-c-project-with-vistual-studio-2017/432620>\
**Category:** C++\
**Tags:** error, unreal-engine, compile, UE4, question, CPP\
**Created:** [August 28, 2018, 9:17am UTC](https://forums.unrealengine.com/t/cannot-compile-unreal-engine-4-c-project-with-vistual-studio-2017/432620 "2018-08-28T09:17:13Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Valentinvis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentinvis/32/1008648_2.png) [@Valentinvis](https://forums.unrealengine.com/u/Valentinvis)\
**Post date:** [July 14, 2024, 11:00am UTC](https://forums.unrealengine.com/t/cannot-compile-unreal-engine-4-c-project-with-vistual-studio-2017/432620/3 "2024-07-14T11:00:37Z")

</div>

An old thread but I also had this problem and this is the result I was getting when searching for a fix.

Short story:  
I forgat to check `Windows application development` in Visual Studio 2022 17.10.4.

Long story:  
I decided to upgrade to `UE 5.4.2` and also update VS 2022 to latest version (by uninstalling my last version, not simply updating it). And when I was compiling UE 5.4.2 I was getting multiple errors `Error LNK1181 cannot open input file 'wininet.lib'`. After lots of failed tests I noticed that I forgat to check in VS `Windows application development` 😅.  
As for why I’m compiling UE 5.4.2 from source is that I added my own way of bringing back the option to not remove Widgets when world gets destroyed when calling `ServerTravel` (which behavior was changed, in the past widgets were kept, but now they are removed, with no option to keep them).  
I did this by adding a bool inside `GameStateBase.h`:

```auto
UCLASS(config = Game, notplaceable, BlueprintType, Blueprintable, MinimalAPI)
class AGameStateBase : public AInfo
{
	GENERATED_UCLASS_BODY()

public:

	//~=============================================================================
	// General accessors and variables

	/** Whether all widgets should be removed when the level/map/world is changed */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = General)
	uint32 bRemoveWidgets : 1;

```

then checking that value inside `GameViewportSubsystem.cpp`:

```auto
	void UGameViewportSubsystem::HandleRemoveWorld(UWorld* InWorld)
{
	bool removeWidgets = true;

	AGameStateBase* gameState = InWorld->GetGameState();
	if (gameState) {
		removeWidgets = gameState->bRemoveWidgets;
	}

	if (removeWidgets)
	{
		//Code that is already in this function by default
	}
}

```

Don’t forget to also add inside this: `#include "GameFramework/GameStateBase.h"`

This way I can have widgets be kept or removed on what levels I want by simply checking that variable or unchecking it inside each level `"Custom"GameState` default value.

---

_[View the full topic](https://forums.unrealengine.com/t/cannot-compile-unreal-engine-4-c-project-with-vistual-studio-2017/432620)._
