Search code examples
c++dllunreal-engine4.libgdcm

Using gdcm libs in UE4


For my UE4 project I want to use the GDCM libraries for C++ to load CT Scans. So I really tried a lot the last few days but I'm still not able to use GDCM... But where is the error? Can someone help me?

  • I created the dll and lib files with CMake (VS 2013 Win64) successfully.
  • I put all the libs in ...Unreal Projects\VolumeImport\ThirdParty\Includes\GDCM\Libraries
  • I added each of the 16 libs in the VolumeImport.Build.cs with PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "gdcmMSFF.lib")); PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "gdcmCommon.lib")); ...
  • I put all the header files in Unreal Projects\VolumeImport\ThirdParty\Includes\GDCM\Includes
  • I set the Includepath to this location in the project properties.
  • I put all the dlls in C:\Windows\System32

Then I used the headers:

#include "VolumeImport.h"

#include <gdcmVersion.h>
#include <gdcmReader.h>
#include <gdcmPixmapReader.h>
#include <gdcmImageReader.h>
#include <gdcmAttributes.h>

bool CTFileLoader::Convert_DICOM()
{
    /** ... other well working code ... */

    gdcm::Trace::SetDebug(false); gdcm::Trace::SetError(true);

    gdcm::ImageReader reader;
    reader.SetFilename(files_to_process[i].c_str()); 
    if(!reader.Read()) { }

}   

And I get an error in the gdcmMediaStorage.h: "error C4515: 'gdcm': Namespace uses itself."

I tried using different includes but this causes diffrent errors in diffrent headers... Is there something wrong with the libraries? But I'm sure they were added, because using only the gdcmTrace.h and the gdcm::Trace::functions works fine.


Solution

  • Now I got the solution:

    • In my VolumeImport.Build.cs I additionally added the DLLs: PublicDelayLoadDLLs.Add(Path.Combine(LibrariesPath, "gdcmMSFF.dll")); ...
    • I changed the gdcmMediaStorage.h file: Comment out the "using namespace gdcm;"
    • Furthermore I had dynamic_cast problems with this big library and it needs to enable RTTI