emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
3k stars 683 forks source link

Liblzma and other packages not being included in cmake compiling. #1364

Closed notsilverhoft closed 6 months ago

notsilverhoft commented 6 months ago

I have been searching for answers for a while and have yet to find one that works. I am trying to build lightspark into wasm, but I need some dependencies, and emscripten does not have ports for them, I am unaware of the method by which I can add these dependencies.

This is what it looks like:

configure: cmake .. -DCMAKE_TOOLCHAIN_FILE=/workspace/WasmFlash/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/workspace/WasmFlash/emsdk/node/16.20.0_64bit/bin/node
-- Gnash not found
-- Checking for module 'liblzma'
--   No package 'liblzma' found
CMake Error at /home/linuxbrew/.linuxbrew/Cellar/cmake/3.28.3/share/cmake/Modules/FindPkgConfig.cmake:619 (message):
  The following required packages were not found:

   - liblzma

Call Stack (most recent call first):
  /home/linuxbrew/.linuxbrew/Cellar/cmake/3.28.3/share/cmake/Modules/FindPkgConfig.cmake:841 (_pkg_check_modules_internal)
  CMakeLists.txt:290 (pkg_check_modules)

-- Configuring incomplete, errors occurred!
emcmake: error: 'cmake .. -DCMAKE_TOOLCHAIN_FILE=/workspace/WasmFlash/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/workspace/WasmFlash/emsdk/node/16.20.0_64bit/bin/node' failed (returned 1)

Thank you in advance to anyone who can answer.

sbc100 commented 6 months ago

If you want to use liblzma you would need to build it yourself using emscripten. You would then either need to reference your version explicitly or install it in the emscripten sysroot such that it can be found at cmake time.

notsilverhoft commented 6 months ago

I did, I have built it, but I have no idea what to do next, where is the sysroot directory? How would I reference it, and if I were to install it, where would I install it? I know how I can use the config prefix to set the directory for make install, but where would I install to, if that was the case?

sbc100 commented 6 months ago

The emscripten sysroot by default lives in cache/sysroot inside the emscripten directory. e.g. /path/to/emscripten/cache/sysroot.

You can either install liblzma there yourself or maybe use the make install rules for liblzma (no sudo/root required remember since this is not in the root directory). If you want the cmake to be able to find it you might also need to install the liblzma pkg-config file in cache/sysroot/lib/pkgconfig.

Alternatively you could just skip the cmake FindPkgConfig thing and just add -I/path/to/lzma/headers and -L/path/to/lxma/libs and -llzma compiler falgs.

notsilverhoft commented 6 months ago

Nevermind I found that setting both PKG_CONFIG_PATH and EM_PKG_CONFIG_PATH to the Liblzma installed lib/pkg-config path, it will find the packages, now I just need to install the other packages needed, thank you, this would be great to add to the wiki, if you want I can make a pr for it.

notsilverhoft commented 6 months ago

I apologize, GitHub did not load your comment, this information is still useful as I did not know you could install directly to emscripten. Thank you.