# How to Use zlib Library in Android Project

**URL:** <https://forums.unrealengine.com/t/how-to-use-zlib-library-in-android-project/489988>\
**Category:** Mobile\
**Tags:** Android-Packaging, Third-Party, unreal-engine, Android, CPP, question\
**Created:** [October 18, 2021, 2:09pm UTC](https://forums.unrealengine.com/t/how-to-use-zlib-library-in-android-project/489988 "2021-10-18T14:09:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bp2016](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bp2016](https://forums.unrealengine.com/u/bp2016)\
**Post date:** [October 18, 2021, 2:09pm UTC](https://forums.unrealengine.com/t/how-to-use-zlib-library-in-android-project/489988/1 "2021-10-18T14:09:09Z")

</div>

Hello,

I’m attempting to use zlib (the version that comes with Unreal Engine) to uncompress some data that comes from a server. I’ve added the following to my .Build.cs file…

AddEngineThirdPartyPrivateStaticDependencies(Target, “zlib”);

…and I’m including the following file in my code: #include “ThirdParty/zlib/zlib-1.2.5/Inc/zlib.h”

Everything works great when I run my game through the editor (which is running on Windows 10). The problem is that when I try to package the game for Android, I get some error messages that appear to be related to zlib:

PackagingResults: Error: ‘\_LARGEFILE64\_SOURCE’ is not defined, evaluates to 0 [-Werror,-Wundef]  
PackagingResults: Error: ‘\_FILE\_OFFSET\_BITS’ is not defined, evaluates to 0 [-Werror,-Wundef]  
PackagingResults: Error: ‘\_LARGEFILE64\_SOURCE’ is not defined, evaluates to 0 [-Werror,-Wundef]  
PackagingResults: Error: ‘\_FILE\_OFFSET\_BITS’ is not defined, evaluates to 0 [-Werror,-Wundef]

I don’t have any clue on what to try to resolve these errors. Does anyone have any experience getting zlib to work in an Android project? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![sarram](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sarram/32/714398_2.png) [@sarram](https://forums.unrealengine.com/u/sarram)\
**Post date:** [November 4, 2022, 9:53am UTC](https://forums.unrealengine.com/t/how-to-use-zlib-library-in-android-project/489988/2 "2022-11-04T09:53:28Z")

</div>

I had the same error. Maybe for somebody it might be useful, how I solved it.

I have noticed, that in zlib (zconf.h) there is comment:

```auto
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
 * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
 * though the former does not conform to the LFS document), but considering
 * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
 * equivalently requesting no 64-bit operations
 */

```

So, I just add:

`#define _LARGEFILE64_SOURCE`

before

`#include <zlib.h>`

and of course after code I used:

`#undef _LARGEFILE64_SOURCE`

Maybe it would help, for somebody.

---

<div class="post-metadata">

**Author:** ![cheetahaa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cheetahaa](https://forums.unrealengine.com/u/cheetahaa)\
**Post date:** [November 6, 2023, 12:24am UTC](https://forums.unrealengine.com/t/how-to-use-zlib-library-in-android-project/489988/3 "2023-11-06T00:24:26Z")

</div>

this only support windows

---

<div class="post-metadata">

**Author:** ![cheetahaa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cheetahaa](https://forums.unrealengine.com/u/cheetahaa)\
**Post date:** [November 16, 2023, 3:29am UTC](https://forums.unrealengine.com/t/how-to-use-zlib-library-in-android-project/489988/4 "2023-11-16T03:29:56Z")

</div>

thanks
