gerstrong/Commander-Genius

emscripten: Could NOT find ZLIB

enderandrew opened this issue · 1 comments

I have tried running emsdk on Windows 11, wsl on Windows, and also on a Debian VM. I get the same behavior in all 3 with the latest emsdk. I tried adding a use flag for zlib in the makefile, but it cannot be found. I have the dev packages installed in Linux and can compile natively for Linux, but not with emsdk for emscripten.

I've tried adding this to the makefile, but it still doesn't work.

if( ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(USE_FLAGS "-sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sUSE_SDL_TTF=2 -sUSE_SDL_MIXER=2 -sUSE_ZLIB=1 --use-port=zlib -sUSE_OPENSSL=1 -sUSE_CURL=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${USE_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${USE_FLAGS}")
set(CMAKE_EXECUTABLE_SUFFIX .html)
else()
find_package(SDL2 REQUIRED)
find_package(SDL2_IMAGE REQUIRED)
find_package(SDL2_TTF REQUIRED)
find_package(SDL2_MIXER REQUIRED)
find_package(ZLIB REQUIRED)
find_package(OpenSSL REQUIRED)
target_link_libraries(untitled OpenSSL::SSL)
find_package(CURL REQUIRED)
endif()
include_directories(
${EMSCRIPTEN_ROOT_PATH}/system
${CMAKE_SOURCE_DIR}/include
${SDL2_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
)

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.55 (165133b1cc977f0b9a277e42ef809b823157189c)
clang version 19.0.0git (https:/github.com/llvm/llvm-project 6c7805d5d186a6d1263f90b8033ad85e2d2633d7)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /root/emsdk/upstream/bin

Failing command line in full:
emcmake cmake ..
configure: cmake .. -DCMAKE_TOOLCHAIN_FILE=/root/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/root/emsdk/node/16.20.0_64bit/bin/node
-- Found Git (/usr/bin/git), executable will get SHA and branch used
-- GIT_SHA = 1645a70
-- GIT_BRANCH = master
-- Setting SYSTEM_DATA_DIR to /usr/share/games
-- Setting build type to 'Release' as none was specified.
-- Preparing the Build-System for Commander Genius
-- Internal Downloader: ON
-- Keen engine build enabled
-- Refkeen engine build enabled
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.1")
CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.28/Modules/FindZLIB.cmake:199 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
src/engine/unzip/CMakeLists.txt:16 (find_package)

Thanks for trying out wasm and emscripten. I tried this in the past and only managed to get the launcher menu working. There are more things to consider when you want to run the full engine, but that was years ago when multithreading support still was at early stage. You might have a different result this time.

About your Zlib question: If you happen to have zlib installed and know where, I would try to set the search paths by giving the variables ZLIB_INCLUDE_DIR and ZLIB_LIBRARY_RELEASE values. Let me know if that helps you. If you don't have zlib for emscripten sdk, you might have to build zlib yourself.