# Generic way to include ThirParty zlib.h

**URL:** <https://forums.unrealengine.com/t/generic-way-to-include-thirparty-zlib-h/877691>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 8, 2023, 5:43am UTC](https://forums.unrealengine.com/t/generic-way-to-include-thirparty-zlib-h/877691 "2023-04-08T05:43:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ManorParmar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ManorParmar](https://forums.unrealengine.com/u/ManorParmar)\
**Post date:** [April 8, 2023, 5:43am UTC](https://forums.unrealengine.com/t/generic-way-to-include-thirparty-zlib-h/877691/1 "2023-04-08T05:43:10Z")

</div>

I want to include zlib.b header file in my code.  
Right now I am on UE5.0 version and I am including as below

```plaintext
#include "ThirdParty/zlib/zlib-1.2.5/Inc/zlib.h"
THIRD_PARTY_INCLUDES_END

```

But when testing the same code on UE5.1, I am getting compile error as Zlib version has changed.

My question is, is there a generic way to include zlib.h instead of a specific version ?

---

<div class="post-metadata">

**Author:** ![DavidMcEwen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DavidMcEwen](https://forums.unrealengine.com/u/DavidMcEwen)\
**Post date:** [April 8, 2023, 10:34am UTC](https://forums.unrealengine.com/t/generic-way-to-include-thirparty-zlib-h/877691/2 "2023-04-08T10:34:59Z")

</div>

If you add it as an engine dependency to the zlib module in your build.cs file it should have the relevant include paths set up. So something like:

`AddEngineThirdPartyPrivateStaticDependencies(Target, "zlib");`

Then in your code you should be able to do:

```auto
THIRD_PARTY_INCLUDES_START
#include "zlib.h"
THIRD_PARTY_INCLUDES_END

```

---

<div class="post-metadata">

**Author:** ![PratikKrishna](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PratikKrishna](https://forums.unrealengine.com/u/PratikKrishna)\
**Post date:** [April 18, 2023, 7:43am UTC](https://forums.unrealengine.com/t/generic-way-to-include-thirparty-zlib-h/877691/3 "2023-04-18T07:43:14Z")

</div>

Thanks David, since we have 3 zlib versions 1.2.12, zlib-1.2.5 & v1.2.8. So my concern is even we provide a specific path for zlib for UE5.1, it might not work for UE 5.0/UE4.27 which uses zlib-1.2.5.  
So my question is how the above solution would work for backward compatibility for all the Unreal versions. Please suggest.  
Is there any macro defined for specific versions of Unreal Engine, that we can use?
