Problem compiling with WebAssembly/Emscripten (ZLIB)

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
MahBoi
Gnoblar
Posts: 1
Joined: Thu Oct 29, 2020 6:55 pm

Problem compiling with WebAssembly/Emscripten (ZLIB)

Post by MahBoi »

Greetings people!

I am new to both Ogre and Emscripten and I'm having trouble understanding how the compilation process works. See, I am using the official snippet provided by the Ogre team to build:

mkdir build-wasm
emcmake cmake .. -DCMAKE_BUILD_TYPE=Release
emmake make

When I do this, emcmake asks me for the ZLIB library, which I include in the CMakeLists.txt in the following way:

if(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(USE_FLAGS "-s USE_ZLIB=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)
endif()

Then the compiler fails like this:

Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)

I know this is not an Ogre-specific issue, but it is of my understanding that ZLIB should be ready to be used by the compiler at this point. What I am doing wrong?

Thank you in advance!
paroj
OGRE Team Member
OGRE Team Member
Posts: 1993
Joined: Sun Mar 30, 2014 2:51 pm
x 1073
Contact:

Re: Problem compiling with WebAssembly/Emscripten (ZLIB)

Post by paroj »

as described here https://ogrecave.github.io/ogre/api/lat ... otoc_md242

Ogre should be building its own dependencies, including upstream zlib
MahBoi
Gnoblar
Posts: 1
Joined: Thu Oct 29, 2020 6:55 pm

Re: Problem compiling with WebAssembly/Emscripten (ZLIB)

Post by MahBoi »

Hi! Thanks for the help, I understand now.

But tell me, how do I manage to get Ogre's dependencies compiled with the snippet provided by Ogre's WebAssembly help? Could you give me a hint about how to get each dependency compiled and linked with Ogre in order to be able to compile an Ogre project later with Emscripten? I appreciate any help because I am kinda confused about how Emscripten works.

Any link or bit of data would do to guide me in the right direction. This information is kinda hard to find by itself.

Kindest Regards!
Last edited by MahBoi on Sat Oct 31, 2020 5:31 am, edited 1 time in total.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1993
Joined: Sun Mar 30, 2014 2:51 pm
x 1073
Contact:

Re: Problem compiling with WebAssembly/Emscripten (ZLIB)

Post by paroj »

you have to do what is done in this cmake script manually:
https://github.com/OGRECave/ogre/blob/7 ... cmake#L110

basically, Emscripten is no different to e.g. Android, where you have to compile all your dependencies yourself.
Post Reply