I went to go package my game which uses a plugin and got the following error:
LogWindows: LoadLibraryWithSearchPaths
failed for file D:/Games/Epic
Games/Projects/GameName/Plugins/PluginName/Binaries/Win64/UE4Editor-PluginName-7396.dll.
GetLastError=126 LogWindows:
FileExists returned 1 for Module
D:/Games/Epic
Games/Projects/GameName/Plugins/PluginName/Binaries/Win64/UE4Editor-PluginName-7396.dll
So we see LoadLibraryWithSearchPaths() fails (later, you can see the proper location is in the full list of search path), and FileExists() returns true (1). The GetLastError() is Windows code for ERROR_MOD_NOT_FOUND.
So I investigated why it could not be found. I believe this may be because of forward slashes. See the following cmd.exe with forward slashes (fails) and backward slashes (file is found).
Forward Slashes (not found, fails):
C:\Windows\System32>dir “D:/Games/Epic
Games/Projects/GameName/Plugins/PluginName/Binaries/Win64/UE4Editor-PluginName-7396.dll”
Volume in drive D is BIGSTORAGE
Volume Serial Number is 141A-DB2CDirectory of D:\Games\Epic
Games\Projects\GameName\Plugins\PluginName\Binaries\Win64File Not Found
Backward slashes (found, works):
C:\Windows\System32>dir “D:\Games\Epic
Games\Projects\GameName\Plugins\PluginName\Binaries\Win64\UE4Editor-PluginName-7396.dll”
Volume in drive D is BIGSTORAGE
Volume Serial Number is 141A-DB2CDirectory of D:\Games\Epic
Games\Projects\GameName\Plugins\PluginName\Binaries\Win6409/23/2017 07:17 PM 264,704
UE4Editor-PluginName-7396.dll
1 File(s) 264,704 bytes
0 Dir(s) 119,722,176,512 bytes free
This looks like the cause of the bug, but I can’t imagine I’m the first to run into this problem? Maybe there is something else going on?
From MSDN on LoadLibrary():
If the function cannot find the
module, the function fails. When
specifying a path, be sure to use
backslashes (), not forward slashes
(/).
The debug spew does show this in the search paths though…
LogWindows: D:\Games\Epic
Games\Projects\GameName\Plugins\PluginName\Binaries\Win64