LNK2001 unresolved external symbal "wchar_t"

So basically when building from UE source release branch at v 5.4.1 (fork(with no changes syncd to main)) I get the following errors, this on VS 2022 Pro 17.10, any ideas how to fix, alas double clicking the error does not take me to the code so bit confused ?

In the Output :
96>Building CmdLink…
03:39:41:476 96>Using Visual Studio 2022 14.38.33138 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
03:39:41:476 96>[Upgrade]
03:39:41:476 96>[Upgrade] Using backward-compatible include order. The latest version of UE has changed the order of includes, which may require code changes. The current setting is:
03:39:41:476 96>[Upgrade] IncludeOrderVersion = EngineIncludeOrderVersion.Oldest
03:39:41:476 96>[Upgrade] Suppress this message by setting ‘IncludeOrderVersion = EngineIncludeOrderVersion.Latest;’ in CmdLink.Target.cs.
03:39:41:476 96>[Upgrade] Alternatively you can set this to ‘EngineIncludeOrderVersion.Latest’ to always use the latest include order. This will potentially cause compile errors when integrating new versions of the engine.
03:39:41:476 96>[Upgrade]
03:39:41:476 96>Determining max actions to execute in parallel (16 physical cores, 32 logical cores)
03:39:41:476 96> Executing up to 16 processes, one per physical core
03:39:41:476 96>Using Parallel executor to run 2 action(s)
03:39:41:476 96>------ Building 2 action(s) started ------
03:39:41:892 96>[1/2] Link [x64] CmdLink.exe
03:39:41:948 96>Module.Core.11.cpp.obj : error LNK2001: unresolved external symbol “wchar_t * GInternalProjectName” (?GInternalProjectName@@3PA_WA)
03:39:41:948 96>Module.Core.14.cpp.obj : error LNK2001: unresolved external symbol “wchar_t * GInternalProjectName” (?GInternalProjectName@@3PA_WA)
03:39:41:948 96>Module.Core.3.cpp.obj : error LNK2001: unresolved external symbol “wchar_t * GInternalProjectName” (?GInternalProjectName@@3PA_WA)
03:39:41:948 96>Module.Core.8.cpp.obj : error LNK2001: unresolved external symbol “wchar_t * GInternalProjectName” (?GInternalProjectName@@3PA_WA)
03:39:41:948 96>Module.Core.9.cpp.obj : error LNK2001: unresolved external symbol “wchar_t * GInternalProjectName” (?GInternalProjectName@@3PA_WA)
03:39:41:948 96>Module.Core.10.cpp.obj : error LNK2001: unresolved external symbol “wchar_t * GInternalProjectName” (?GInternalProjectName@@3PA_WA)
03:39:41:948 96>Module.Core.3.cpp.obj : error LNK2001: unresolved external symbol “wchar_t const * const GForeignEngineDir” (?GForeignEngineDir@@3PEB_WEB)
03:39:41:948 96>…\Binaries\Win64\CmdLink.exe : fatal error LNK1120: 2 unresolved externals
03:39:41:948 96>Total time in Parallel executor: 0.48 seconds
03:39:41:948 96>Total execution time: 81.76 seconds
03:39:41:983 96>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command “…..\Build\BatchFiles\Build.bat CmdLink Win64 Development -WaitMutex -FromMsBuild -architecture=x64” exited with code 6.
03:39:41:983 96>Done building project “CmdLink.vcxproj” – FAILED.

I’m not sure if this is correct, but I added the following code between the includes and enum EErrorMessage (~ln9) to CmdLink.cpp and the CMDLink project compiled. It’s similar to what they do in other Programs if you do a Find in files for GInternalProjectName.

#if !defined(UE_PROJECT_NAME)
TCHAR GInternalProjectName[64] = TEXT(“CmdLink”);
#else
TCHAR GInternalProjectName[64] = TEXT(PREPROCESSOR_TO_STRING(UE_PROJECT_NAME));
#endif
IMPLEMENT_FOREIGN_ENGINE_DIR()

3 Likes

The fix from ue5-main upstream is to add

#include "RequiredProgramMainCPPInclude.h"

IMPLEMENT_APPLICATION(CmdLink, "CmdLink")

before the enum EErrorMessage declaration and to add "Projects" to the PrivateDependencyModuleNames.

It can already be done in 5.4.2 manually.

1 Like

I’ve add this 2 line in CmdLink.cpp, and add “Projects” to PrivateDependencyModuleNames in Launch.Build.cs, but it still compiles ““Interfaces/IPluginManager.h”: No such file or directory CmdLink”, sorry did i make any mistake?

It should be in CmdLink.Build.cs not Launch.Build.cs ?

Tried this my build still failed and have some “other -new issues”

I’ve got the same error. Any solution?

Thanks man, you’re a hero! It solved my problem.

1 Like

Hi! I already added the screenshot. Copy the code & paste it to CmdLink.cpp

just wanted to confirm that this fix worked for me as well. the code that you posted are using curly brackets around CmdLink, which caused errors for me. The code I used was the following:

#if !defined(UE_PROJECT_NAME)
TCHAR GInternalProjectName[64] = TEXT("CmdLink");
#else
TCHAR GInternalProjectName[64] = TEXT(PREPROCESSOR_TO_STRING(UE_PROJECT_NAME));
#endif
IMPLEMENT_FOREIGN_ENGINE_DIR()

Added right after include statements in the ...\Engine\Source\Programs\CmdLink\Private\CmdLink.cpp. Straight brackets around "CmdLink" seemed important.

Also, a trick i discovered to quickly test this is to only build the specific module in visual studio. So when you open up the Unreal Engine solution, you can open the solutions explorer (view > solutions explorer). In there, open the “programs” folder and scroll down to find the module that causes errors (in this case, CmdLink). Right click on it and hit “build”. This is A LOT quicker than rebuilding the entire solution and makes error fixing easier.