Emscripten: Document embuilder (as a way to build and install libraries and ports manually)

Created on 31 May 2018  路  11Comments  路  Source: emscripten-core/emscripten

Is either possible?

I'm trying to cross-compile an SDL-based project that doesn't use configure on Linux. So far tried using emmake make -s USE_SDL=2 USE_SDL_IMAGE=2 USE_SDL_TTF=2 and CFLAGS="-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_TTF=2" but I still only have SDL2 port in ~/.emscripten_ports and emmake is failing to find SDL_image and SDL_ttf.

The terminal output looks like this, just in case I'm interpreting it wrong:

Package SDL2_image was not found in the pkg-config search path.
Perhaps you should add the directory containing `SDL2_image.pc'
to the PKG_CONFIG_PATH environment variable
No package 'SDL2_image' found
Package SDL2_ttf was not found in the pkg-config search path.
Perhaps you should add the directory containing `SDL2_ttf.pc'
to the PKG_CONFIG_PATH environment variable
No package 'SDL2_ttf' found
good first bug help wanted

Most helpful comment

Another undocumented quirk: emmake (and probably all the commands since the code is in shared.py) takes PKG_CONFIG_PATH from EM_PKG_CONFIG_PATH. That's why specifying PKG_CONFIG_PATH didn't work.

All 11 comments

You can use embuilder (in the main repo, alongside emcc) to install them manually. Instructions are in the --help.

Perhaps embuilder is not documented well enough? Maybe there are places in the docs we should add it to.

Thanks @kripken ! That's an understatement. I've gone through emscripten.org and googled a lot. Never even seen a reference to the tool.

Yes, good point, it does seem to be undocumented. I'll rename this issue to focus on that. Would be great to have a PR adding it - probably to the "Building Projects" page, at minimum.

I'd be happy to make a PR when I've used embuilder successfully. Currently, I've encountered the following issues:

  • Embuilder doesn't create a .pc file required by emcc. Should embuilder run configure script in each port when it's installed or is this issue more like something specific to the non-configure build process I'm trying to run with emscripten?

  • Even when pc files are created by running configure scripts manually, emcc cannot find them. Adding the paths to PKG_CONFIG_PATH does nothing. I've found similar issues in other repos where python runs pkg-config as a subprocess, which doesn't get the same env variables as the python script the user ran. Going to play with subprocess.run to see if I can make it pass the env variables to the subprocess like Popen can: https://stackoverflow.com/questions/2231227/python-subprocess-popen-with-a-modified-environment

note: I neither do c++ nor python regularly so I have no idea what I'm doing :)

I'm not familiar with .pc files myself. In which port are they necessary, and on which platform? In general all ports are tested (test_embuider) and should work, so I suspect you are seeing a platform-specific issue of some sort.

I'm looking at sdl2-image and sdl2-ttf on linux.

You can read more about .pc files at https://autotools.io/pkgconfig/file-format.html

The way I understand it, those files are read by pkg-config to check for existence and version of a library, like a simplified equivalent of package.json from javascript world.

What those ports do have are .pc.in files, which are supposed to be templates used to generate .pc files, so there's obviously a step missing, either in what embuilder does or when those ports were built.

Either way, if people are using those ports successfully with configure scripts, it might mean that the issue is related to the non-configure build I'm trying to do with emscripten. The makefile is https://github.com/CleverRaven/Cataclysm-DDA/blob/master/Makefile

Another undocumented quirk: emmake (and probably all the commands since the code is in shared.py) takes PKG_CONFIG_PATH from EM_PKG_CONFIG_PATH. That's why specifying PKG_CONFIG_PATH didn't work.

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

Hitting this issue as well. Can it be revisited?

Another undocumented quirk: emmake (and probably all the commands since the code is in shared.py) takes PKG_CONFIG_PATH from EM_PKG_CONFIG_PATH. That's why specifying PKG_CONFIG_PATH didn't work.

Thanks for the tip.

IIUC this issue is about embuilder and whether its documented. There are separate issues coming here such as "why doesn't embuilder install pc files", and "whats the best way to build and install external projects so that are accessible to emscripten". There are several other open issues related to this too (e.g. https://github.com/emscripten-core/emscripten/issues/6664) so it clear there is still work to do.

However this issue, as titled doesn't seem relevant. embuilder is look that simply builds the builtin emscripten libraries in the same way that -s USE_ZLIB. Its not designed to build arbitrary stuff like emmake and emconfigure are. So I think we should close this particular issue in favor of other more specific ones. Assuming others agree?

To be specific EM_PKG_CONFIG_PATH should be documented.

I've spent several days trying to build a set of libraries with dependencies between them before finding this thread. EM_PKG_CONFIG_PATH was the solution for my issues and it is really unfortunate that I couldn't find it anywhere else.

Was this page helpful?
0 / 5 - 0 ratings