Search code examples
cmakegithub-actionszlib

Linker error when testing GitHub Actions locally using act: undefined reference to symbol 'inflateEnd'


I am trying to test a GitHub Actions workflow locally using act, but I'm encountering a linker error related to zlib when building my CMake project. The error message is as follows:

/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libcurl.so: undefined reference to symbol 'inflateEnd'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libz.so: error adding symbols: DSO missing from command line

This error seems to be related to the linking process and the zlib library. I've already tried specifying -lz in CMAKE_CXX_FLAGS, but it doesn't seem to resolve the issue.

Here's the relevant section of my GitHub Actions workflow (main.yml):

- name: Install dependencies
  run: |
    sudo apt-get update
    sudo apt-get install -y rapidjson-dev libcurl4 libcurl4-openssl-dev python3 python3-dev zlib1g-dev zlib1g cmake

I'm wondering if there's something I'm missing in my setup or if there's a different approach I should take to resolve this linker error when testing GitHub Actions locally using act. Any insights or suggestions would be greatly appreciated. Thank you!

Here's a snippet of my CMakeLists.txt:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lz")

...

target_link_libraries(myproject PUBLIC z)

Despite this modification, the issue persists. I'm not sure why the linker is unable to link to libz.


Solution

  • In the end, I solved it by using container to use a custom docker instance where it compiled(in my instance ubuntu:18.04), and after some hiccups I settled on the following.

    if(ZLIB_FOUND)
        message(STATUS "ZLIB_LIBRARIES: ${ZLIB_LIBRARIES}")
        target_link_libraries(myproject PUBLIC ${ZLIB_LIBRARIES})
    else()
        message(FATAL_ERROR "ZLIB not found. Please make sure zlib is installed.")
    endif()