# 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:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_6450b452](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6450b452](https://forums.unrealengine.com/u/anonymous_user_6450b452)\
**Post date:** [August 28, 2018, 9:17am UTC](https://forums.unrealengine.com/t/cannot-compile-unreal-engine-4-c-project-with-vistual-studio-2017/432620/1 "2018-08-28T09:17:13Z")

</div>

I created a c++ project in unreal engine 4.20.2.Then,I got an error said no projectname.dll finded and i should compile manully with visual studio 2017.When i start my compilation with vs2017 i got 1 waring and 3 errors:

```
Warning MSB4011 "D:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Makefile.props" cannot be imported again. 
It was already imported at "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.cpp.props (31,3)". 
This is most likely a build authoring error. This subsequent import will be ignored. [D:\Yanglixiao\ueproj\why\Intermediate\ProjectFiles\why.vcxproj]

Error LNK1181 cannot open input file 'wininet.lib' why D:\Yanglixiao\ueproj\why\Intermediate\ProjectFiles\LINK 1   

Error MSB3073 The command ""D:\Program Files\Epic Games\UE_4.20\Engine\Build\BatchFiles\Rebuild.bat" whyEditor Win64 Development "D:\Yanglixiao\ueproj\why\why.uproject" -WaitMutex -FromMsBuild" exited with code -1. why C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets

```

I searched the error and i got “[New C++ Project fails to compile using UE 4.15 and VS 2017 Community Edition - LINK : fatal error LNK1181: cannot open input file 'ws2\_32.lib' - C++ - Epic Developer Community Forums](https://answers.unrealengine.com/questions/597939/new-c-project-fails-to-compile-using-ue-415-and-vs.html)”,howerer, it didn’t works for me.(I had installed vs2015 before and i had unintalled it already) I thought the "wininet.lib"is the key and i searched it and i find it in “C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\x86” and there are many other copies.The configuration is a mess for me right now. I think i’m going crazy after reinstall&repair vs2017 and ue4 many times.

---

<div class="post-metadata">

**Author:** ![bellicapax](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bellicapax](https://forums.unrealengine.com/u/bellicapax)\
**Post date:** [July 27, 2021, 7:08pm UTC](https://forums.unrealengine.com/t/cannot-compile-unreal-engine-4-c-project-with-vistual-studio-2017/432620/2 "2021-07-27T19:08:59Z")

</div>

Since this is the first result for the `wininet.lib` linker issue, I thought I’d share my solution. What really fixed it for me was regenerating the project files via `GenerateProjectFiles.bat`

---

<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.
