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

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

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

1 Like

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

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:

	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.

1 Like