I tried doing some atl stuff in Unreal and would only get tons of compile errors
I tried this trick but it does not work anymore…
include <AllowWindowsPlatformTypes.h>
include <windows.h>
include <dshow.h>
include <atlbase.h>
include <initguid.h>
include <HideWindowsPlatformTypes.h>
So I thought I could try another way…
Create a non unreal project but include headers from Unreal for the one function that would need it.
The atl stuff in that project worked…but could not include any unreal headers.
Now I am NOT referring to adding the header locations in the list for include files.
That part I did…
but if I do this…note I use “<” and “>” and not quotes.
include <CoreMinimal.h>
include <Engine/Texture2D.h>
I get this error
#error: Exactly one of [UE_BUILD_DEBUG UE_BUILD_DEVELOPMENT UE_BUILD_TEST UE_BUILD_SHIPPING] should be defined to be 1
I tried this, but it did not work
#define UE_BUILD_DEBUG
also tried this
#define UE_BUILD_DEBUG 1
For UE5.2 TO DO ATL STUFF (USING ATLBASE.H)
This torturous mess seemed to work.
Notes!
You have to add the include directories that you get errors for into the “include paths” in your UE5.2 project settings.
There is a mix and match of using “<” + “>” and quote symbols for include stuff.
Again make sure you modify your project include directories settings.
In YOUR *.CPP file add this as last block of include statements.(below)
In your *.Build.cs file add these two lines
PCHUsage = PCHUsageMode.NoSharedPCHs;
PublicAdditionalLibraries.Add(“atls.lib”);
(below is include stuff)
#define SKIP_DXTRANS
#define _CRT_SECURE_NO_WARNINGS
include “Windows/AllowWindowsPlatformTypes.h”
#pragma warning(push)
#pragma warning(disable: 4191) // warning C4191: ‘type cast’ : unsafe conversion
#pragma warning(disable: 4996) // error C4996: ‘GetVersionEx’: was declared deprecated
#define WIN32_LEAN_AND_MEAN
include <Windows.h>
// atltransactionmanager.h doesn’t use the W equivalent functions, use this workaround
#ifndef DeleteFile
#define DeleteFile DeleteFileW
#endif
#ifndef MoveFile
#define MoveFile MoveFileW
#endif
#ifndef LoadString
#define LoadString LoadStringW
#endif
#ifndef GetMessage
#define GetMessage GetMessageW
#endif
#define InterlockedIncrement64 _InterlockedIncrement64
#define InterlockedDecrement64 _InterlockedDecrement64
LONG
InterlockedIncrement(
Inout Interlocked_operand LONG volatile* Addend
);
LONG
InterlockedDecrement(
Inout Interlocked_operand LONG volatile* Addend
);
include <atlbase.h>
#undef DeleteFile
#undef MoveFile
#pragma warning(pop)
include “Windows/HideWindowsPlatformTypes.h”
If anybody tries this for UE5.2, post reply on how well it worked out…(or not worked out).
Like others I did not see an up to date fix for issue.
slight modification plus easier to copy
#define SKIP_DXTRANS
#define _CRT_SECURE_NO_WARNINGS
#include "Windows/AllowWindowsPlatformTypes.h"
#pragma warning(push)
#pragma warning(disable: 4191) // warning C4191: 'type cast' : unsafe conversion
#pragma warning(disable: 4996) // error C4996: 'GetVersionEx': was declared deprecated
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
// atltransactionmanager.h doesn't use the W equivalent functions, use this workaround
#ifndef DeleteFile
#define DeleteFile DeleteFileW
#endif
#ifndef MoveFile
#define MoveFile MoveFileW
#endif
#ifndef LoadString
#define LoadString LoadStringW
#endif
#ifndef GetMessage
#define GetMessage GetMessageW
#endif
#define InterlockedIncrement64 _InterlockedIncrement64
#define InterlockedDecrement64 _InterlockedDecrement64
LONG
InterlockedIncrement(
_Inout_ _Interlocked_operand_ LONG volatile* Addend
);
LONG
InterlockedDecrement(
_Inout_ _Interlocked_operand_ LONG volatile* Addend
);
#include <atlbase.h>
#undef DeleteFile
#undef MoveFile
#undef LoadString
#undef GetMessage
#pragma warning(pop)
#include "Windows/HideWindowsPlatformTypes.h"
NOTE:
Because UE has generated header files in your user class header files…
This seems to mess up the normal build process.
You MAY have to build your project TWICE. (that’s build, not rebuild)
The first build WILL give you an error about atlbase.h
This is indirectly related to the generated *.h file
example :
#include "WebCam.generated.h"
The SECOND build should work and build with no errors. (it does for me)