Set .dll directory for build

Lately I’m struggling to include PCL in UE4 project - and I almost done it. For comparison I made clear example project in Qt (without UE) - and what I saw for the first time was clear compiling, and after this error with call for dll’s (VTK libraries). When I set VTK path I was able to run program correctly.

After this I included whole project in UE4 - I created simple AActor class with body of source in the constructor. Project compiled without problem (after ~70 hours of struggling), but:

  1. Constructor doesn’t start properly - I guess because it doesn’t find necessary dll’s and just kills a function
  2. After shutting down Project doesn’t start until I erase whole body of constructor (but includes stays).

Only message I get from Editor was:

 "The game module 'TerrainSandbox2' could not be loaded. There may be an operating system error or the module may not be properly set up." 

The log file states (after a lot of cuts):

Log file open, 09/09/16 02:20:05
LogInit:Display: Running engine without a game
LogPlatformFile: Not using cached read wrapper
LogInit:Display: Loading recent project file: ../../../../../../UE4 Projects/TerrainSandbox2/TerrainSandbox2.uproject
LogInit:Display: RandInit(1433366134) SRandInit(1433366134).
LogTaskGraph: Started task graph with 5 named threads and 8 total threads with 1 sets of task threads.
LogStats: Stats thread started at 0.083168

[2016.09.09-00.20.39:640][243]LogAssetTools:Warning: Failed to import 'C:\Program Files\VTK 6.3.0\bin\vtkCommonColor-6.1.dll'. Unknown extension 'dll'.
[2016.09.09-00.32.15:806][364]Cmd: QUIT_EDITOR (now there is a lot of closing plugins and modules)

PCL as in the point cloud library that uses the GPU for rendering and such?

Yes, it has implemented CUDA. But standard it uses CPU. For now I don’t care how does it work, I know it works pretty well.

Well, then you are out of luck. For some reason UE4 does not give you access to the GPU drivers so it fails when you try to wrangle the function pointers. As such you can include it, but you cant write any code that uses the GPU. The moment you try it wont start.

I know of no way to fix this and the only way to do this would be to write a program outside of UE4 that communicates with UE4 and sends teh data back and forth.

Hm, not good, but I think the problem lies in not being able to link dll libraries, not the very nature of included library. I had already change the bUseRTTI flag to true.

No, I had the exact same problem that you have and I failed exactly the same way when I tried to launch it after I included OpenGL libraries. The moment I asked for the driver I crashed. That is why the launch stops as you described. There is no way around it as far as I know.

Remove all the code that uses the GPU and it should run fine.

Well, I found complex answer for my problem. The general solution - I still don’t know if importing .dlls were necessary - was to put into config .cs file - here would be called "MyProject.Build.cs - commands to add strings with file paths and filenames for includes, libs and dlls. Commands were:

 PrivateIncludePaths.Add("../ThirdParty/PCL_1.7.2/include/pcl-1.7");

    PrivateIncludePaths.Add("../ThirdParty/boost_1_61_0/");
    PublicLibraryPaths.Add("../ThirdParty/boost_1_61_0/lib64-msvc-14.0");

    PrivateIncludePaths.Add("../ThirdParty/PCL_1.7.2/3rdParty/Eigen/eigen3");
    PrivateIncludePaths.Add("../ThirdParty/PCL_1.7.2/3rdParty/FLANN/include");
    PrivateIncludePaths.Add("../ThirdParty/PCL_1.7.2/3rdParty/Qhull/include");
    PrivateIncludePaths.Add("../ThirdParty/PCL_1.7.2/3rdParty/VTK/include");

    PublicLibraryPaths.Add("../ThirdParty/PCL_1.7.2/lib");
    PublicLibraryPaths.Add("../ThirdParty/PCL_1.7.2/bin");

    PublicLibraryPaths.Add("../ThirdParty/PCL_1.7.2/3rdParty/FLANN/lib");
    PublicLibraryPaths.Add("../ThirdParty/PCL_1.7.2/3rdParty/VTK/lib");
    PublicLibraryPaths.Add("../ThirdParty/PCL_1.7.2/3rdParty/VTK/bin");
    PublicLibraryPaths.Add("../ThirdParty/PCL_1.7.2/3rdParty/Qhull/bin");
    PublicLibraryPaths.Add("../ThirdParty/PCL_1.7.2/3rdParty/FLANN/bin");

    PublicAdditionalLibraries.Add("pcl_common_release.lib");
    PublicAdditionalLibraries.Add("pcl_features_release.lib");
    PublicAdditionalLibraries.Add("pcl_filters_release.lib");
    PublicAdditionalLibraries.Add("pcl_io_ply_release.lib");
    PublicAdditionalLibraries.Add("pcl_io_release.lib");
    PublicAdditionalLibraries.Add("pcl_kdtree_release.lib");
    PublicAdditionalLibraries.Add("pcl_keypoints_release.lib");
    PublicAdditionalLibraries.Add("pcl_octree_release.lib");
    PublicAdditionalLibraries.Add("pcl_outofcore_release.lib");
    PublicAdditionalLibraries.Add("pcl_people_release.lib");
    PublicAdditionalLibraries.Add("pcl_recognition_release.lib");
    PublicAdditionalLibraries.Add("pcl_registration_release.lib");
    PublicAdditionalLibraries.Add("pcl_sample_consensus_release.lib");
    PublicAdditionalLibraries.Add("pcl_search_release.lib");
    PublicAdditionalLibraries.Add("pcl_segmentation_release.lib");
    PublicAdditionalLibraries.Add("pcl_surface_release.lib");
    PublicAdditionalLibraries.Add("pcl_tracking_release.lib");
    PublicAdditionalLibraries.Add("pcl_visualization_release.lib");

    PublicDelayLoadDLLs.Add("pcl_common_release.dll");
    
    bUseRTTI = true;
    bEnableExceptions = true;

Et cetera et cetera, I included about 300 different dlls (thank gods for in-shell scripts). My project were working, sometimes were starting, sometimes not, sometimes it were crushing after calling the constructor. Obviously I couldn’t work like that. I found the other solution - my own custom .dll file! It doesn’t requires any imports and libraries once it were compiled. I don’t know what happens if .dll uses CUDA - maybe soon I’ll find out. For now, my problem is solved, and I strongly encourage to learn about dlls any future student.

Hm, now I found that PublicDelayLoadDLL needs to refer into /Binaries/Win64 folder. Because I have only one dll file I just copy it into folder, so I don’t bother looking for refering into another folder.