DLL Not Loading Anymore

I tried this with P1 and now with P3 with the same result. My application links a third party DLL. The DLL is in a directory that is on the PATH variable. Up to version 4.10 there was no problem starting this configuration. The 4.11 previews give me the error message that the DLLs are not found.
The only way I can start the appllication now is when I copy these DLLS either in the system32 directory or in the same directory the application starts from.

I know, your developers have already said, this is a windows thing, but my observation is this: When nothing in my setup changes except the Unreal version, it must be an Unreal thing. Maybe they are messing with the DLL search path or the safe DLL loading mode, I have no idea, but fact is that a perfectly good configuration under UE 4.10 does not start under 4.11

FYI: To link the LIB part of the DLL I’m using lines like this:

#pragma comment( lib, “D:/Data/Mikaboshi2/Programming/Output/Network_64.lib”)

which is also the same directory where the DLLs are and which is set in the Windows PATH variable

Ok, I made a to prove my point. Compile the project with 4.10. For the DLL output directory, chose any directory that’s on your PATH. Obviously you have to enter another directory that what’s in my project. Run the project and it will start without problem.

Then just change the engine version to 4.11, load the project, you have to add the DLL project again since the new projectfiles wont remember it. Compile and run again and you get a DLL not found error.

This must be a problem that is caused by UE 4.11 theres no other explanation that I could think of.

The respective lines to bind and use the DLL are in:
DLLTest.cpp
DLLTestGameMode.cpp

I understand that the developers have a huge workload right now with the new version coming up, but has anybody verified this here? it is a problem that will affect people as soon as the new version is released.

Hello,

Thank you for reporting this. I don’t have much information to provide at the moment but I wanted to at least leave a message here to let you know that I’m looking into this for you. I’ll let you know as soon as I know more.

I’m still looking into this issue, Wallenstein. I just wanted to let you know I haven’t forgotten about your issue.

Hello, sorry for the delay!

I suggest you take a look at what I’m doing in WmfMedia, because it is the same scenario. I’m linking a static library via #pragma comment and then have Windows locate the run-time DLL on its own in System32.

Here are the relevant lines in the source code: .com/EpicGames/UnrealEngine/blob/4.11/Engine/Plugins/Media/WmfMedia/Source/WmfMedia/Private/WmfMediaModule.cpp#L9

Also make sure your Build.cs file is set up correctly: .com/EpicGames/UnrealEngine/blob/4.11/Engine/Plugins/Media/WmfMedia/Source/WmfMedia/WmfMedia.Build.cs#L40

PS: If Windows can’t find your DLL in another non-standard directory, make sure your PATH is indeed set up correctly. We do not (in fact cannot) interfere with how Windows looks up DLLs. This all happens automatically very early on program startup (if linked into the Engine) or DLL initialization (if linked into a plug-in) even before UE4 code is entered.

Also be aware that any of your users will also need their PATH to be set up correctly. It might be better to either rely on the default installation path (when installing a 3rd party SDK, they usually set up PATH correctly), or to include the dependencies directly with your plug-in (check out VlcMedia for an example of how to do that - you basically force-load the DLL once on startup).

The fact is, that the same project behaves differently in V4.10 than in 4.11

I have already said that DLLs are still found if
A) in System32
B) in the same directory the game DLL was loaded from

but that’s not the problem. DLLS are NOT found when in a directory that is in the PATH variable. My path is set correctly. It works in 4.10 and I doublechecked the path variable as well.

I dont have access to your links, probably because I dont have an account on that site, but again it is irrelevant if it loads DLLs from System32 because I know that it works

Question:
Have you tried out my test program in UE4.10 and then in UE4.11 and noticed any difference or not? I really dont want to sound like a smart aleck, but if that shows the same problem for you as it does for me, then logic dictates that the fault is with version 4.11

Is there any answer to this?

Hello,

I’ve taken a look at your project but the issue is that it won’t compile correctly for me. After changing the line in DLLTest.cpp and fixing the output directory, it results in generating the .dll but not actually compiling successfully, the error is MSB3073. After converting the project from 4.10 to 4.11 it doesn’t seem to include the other module in the project generation and fails on that front with a “Failed to initialize the engine (PreInit failed).”. Is there a step I may be missing to get this working so that I can see the issue you’re mentioning?

The DLL is really not special. It is infact just the default DLL framework with a sample function that VS creates when you make a DLL project. You can create that one sperately and you dont even need to add it to the UE project strictly speaking.

I include a compiled version of the DLL here in case you have problems with it. just put all into a directory that is in your path. You need to link the LIB part in DLLTest.cpp.
link text

I looked up the error you mentioned and there seems not to be much help out there, but it may have something to do with a copy command after creation of the output and use of “/” instead of ""?
Although I did not include any post build event anywhere, so I dont know if these things here apply, You could even create your own DLL with the VS Wizard, just using the default settings which will create the “fnTheDLL();” function that my testprogram calls.

http:///questions/25566834/visual-studio-post-build-copy-command-error-msb3073-exit-code-1
http:///questions/17075279/how-do-i-fix-msb3073-error-in-my-post-build-event

I have a quick question that could be making a difference. Are you using a binary version of 4.10 and 4.11 or are you using builds built from source that you got from github? Did you edit any of the source if so?

I’m always using the version I get from the Unreal startup application, I don’t use github at all

Unfortunately, unless this project will compile, I won’t be able to test to see if I’m able to get the problem you’re receiving with this project. To be exact on the steps that I took, I’ll list them here.

  1. I downloaded the DLLTest., unzipped it to a location on my D:\ drive and opened the .sln file.
  2. Created folder in D:\ called MyDLL and added it to my Path variable like so: D:\MyDLL\
  3. Edited line 7 of DLLTest.cpp to be #pragma comment (lib, "D:\MyDLL\TheDLL.lib")
  4. Right-clicked the “TheDLL” project to open the Properties window and changed the Output Directory to D:\MyDLL\
  5. Tried without the .dll provided in your later post and was given an error about not being able to open the .lib file
  6. Added the .DLL provided to the directory.
  7. Attempted to compile and received this output log

Two things that look weird.
A) The error file you get contains a reference to D:\UnrealEngine\Epic Games\4.10\Engine\Build\BatchFiles\Build.bat which is my locatio where I have UE installed. Why would you get that location in your project? I can’t answer that but it loos to me there is something in the project file that refers to my location. Perhaps you have to “switch UE version” first and generate new project files?

B) you give the lib as "D:\MyDLL\TheDLL.lib" . I would imagine that the last backslash could cause an error. It’s a filename after all and if it’s trailed with a '' this might be the reason why the LIB file could not be found

I’m surprised I didn’t notice that first one. The reason your path was listed is due to me using the project you provided. Upon generating the project files again, I had to add the .dll’s module manually via the File > Add > Existing Project menu and then it would compile for 4.10. Upon converting the project to 4.11, I did discover another bug. I’m not sure if this is directly related to your problem. When I converted the project to 4.11, I was given a VS2013 solution instead of a VS2015 solution. This causes the project solution and the module for building the DLL to become incompatible. Could this be the cause of the issue you’re running into?

I don’t have VS 2013 installed, and I dont remember that VS would give me the option of converting a project from 2013 to 2015 when I loaded it in UE4.11. Perhaps your system generates the VS2013 file because you have that compiler installed.
So are you saying that after you converted the project to UE 4.11 and then converted the VS project file to 2015 you were able to run the without a “DLL not found error” and it loaded the DLL from your PATH?

I’ve reported the issue with 4.11 generating 2013 projects, but in the meantime I uninstalled 2013 to try to avoid it but it wouldn’t stop generating 2013 projects so I just went with it. Opened the .sln in 2015 and then added the “TheDLL” project to the solution and built without error in 4.11. I have not received any sort of error claiming that it was unable to load the DLL.

UBT will generate a 2013 solution if you have certain platform SDKs installed. There are still some platforms that do not support VS2015 yet.