# \[C\] Gzip Compression #CR8 - gzip functions considered undefined references

**URL:** <https://forum.codecrafters.io/t/c-gzip-compression-cr8-gzip-functions-considered-undefined-references/9200>\
**Category:** Challenges\
**Tags:** challenge:http-server\
**Created:** [April 22, 2025, 4:03pm UTC](https://forum.codecrafters.io/t/c-gzip-compression-cr8-gzip-functions-considered-undefined-references/9200 "2025-04-22T16:03:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brycegallo](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/brycegallo/32/9320_2.png) [@brycegallo](https://forum.codecrafters.io/u/brycegallo)\
**Post date:** [April 22, 2025, 4:03pm UTC](https://forum.codecrafters.io/t/c-gzip-compression-cr8-gzip-functions-considered-undefined-references/9200/1 "2025-04-22T16:03:21Z")

</div>

I’ve been stuck on stage Gzip Compression #CR8 for a while now and even checked other people’s code examples to see they seem to be using the same gzip functions as me.

Some notes about my environment and code

- i’m coding on ubuntu and i installed the cmake snap after seeing that might be an issue
- i’m using the codecrafters cli to submit my code for tests
- i just learned about the codecrafters github app so i could have my code checked for assistance with this issue, here’s the code in the repo [brycegallo-codecrafters-http-server-c/src/main.c at 86e5241fe7ba3fa21183da387848867cf92f54ee · brycegallo/brycegallo-codecrafters-http-server-c · GitHub](https://github.com/brycegallo/brycegallo-codecrafters-http-server-c/blob/86e5241fe7ba3fa21183da387848867cf92f54ee/src/main.c#L112) i apologize in advance for the state of my code, i’m still very new to C

and here’s the output i’m currently seeing

```auto
[compile] -- Build files have been written to: /app/build
[compile] [50%] Building C object CMakeFiles/http-server.dir/src/main.c.o
[compile] [100%] Linking C executable http-server
[compile] /usr/bin/ld: CMakeFiles/http-server.dir/src/main.c.o: in function `gzip_deflate':
[compile] main.c:(.text+0x8d): undefined reference to `deflateInit2_'
[compile] /usr/bin/ld: main.c:(.text+0xa7): undefined reference to `deflateBound'
[compile] /usr/bin/ld: main.c:(.text+0x105): undefined reference to `deflate'
[compile] /usr/bin/ld: main.c:(.text+0x11f): undefined reference to `deflateEnd'
[compile] collect2: error: ld returned 1 exit status
[compile] gmake[2]: *** [CMakeFiles/http-server.dir/build.make:97: http-server] Error 1
[compile] gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/http-server.dir/all] Error 2
[compile] gmake: *** [Makefile:91: all] Error 2
[compile] Looks like your code failed to compile.
[compile] If you think this is a CodeCrafters error, please let us know at hello@codecrafters.io.

```

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [April 23, 2025, 6:45am UTC](https://forum.codecrafters.io/t/c-gzip-compression-cr8-gzip-functions-considered-undefined-references/9200/4 "2025-04-23T06:45:28Z")

</div>

Hey @brycegallo, you can add the following two lines to `CMakeLists.txt` to resolve the issue:

```auto
find_package(ZLIB REQUIRED)
target_link_libraries(http-server PRIVATE ZLIB::ZLIB)

```

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/b/b4eefbd0eaaee7b754801d691d7e92c2e36a83d7.png)

This ensures that your project links correctly against the Zlib library.

---

<div class="post-metadata">

**Author:** ![brycegallo](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/brycegallo/32/9320_2.png) [@brycegallo](https://forum.codecrafters.io/u/brycegallo)\
**Post date:** [April 23, 2025, 1:10pm UTC](https://forum.codecrafters.io/t/c-gzip-compression-cr8-gzip-functions-considered-undefined-references/9200/6 "2025-04-23T13:10:02Z")

</div>

Thank you so much! everything’s working now

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [April 28, 2025, 1:10pm UTC](https://forum.codecrafters.io/t/c-gzip-compression-cr8-gzip-functions-considered-undefined-references/9200/7 "2025-04-28T13:10:20Z")

</div>

Closed on April 28, 2025, 1:10pm UTC

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
