Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Emscripten build process for jq
emconfigure ./configure --disable-maintainer-mode
make clean
env CCFLAGS=-O2 emmake make LDFLAGS=-all-static CCFLAGS=-O2 -j4
cp jq jq.o
emcc -O2 jq.o -o jq.js

This comment has been minimized.

Copy link
Owner Author

passcod commented Mar 11, 2015

passcod@archpire ~/c/c/jq> echo '[1,2,3,4]' | js jq.js '.'
jq.js:3:1031 warning: asm.js type error: 'min' is not a standard Math builtin

This comment has been minimized.

Copy link

rossillingworth commented Sep 7, 2015

I have been trying to compile jq with emscripten for most of the afternoon without success.
So far, I have needed to build Bison3, and locate a working Oniguruma src tarball.

I can build jq perfectly to the normal cmd, but emscripten continues to fail.
As you seem to have had some success, I was hoping you might share your experiences.

Can you give me a few more details about how you did it?
Do you know which jq version you compiled? (I am using 1.5)
Do you know which emscripten version you used?
I assume you used the tarball?

FYI: I am running on fedora 20, and configure is no longer complaining.

I have followed your instructions to the letter,
but when I try to run the final step, I get...

/home/rillingworth/tools/emsdk_portable/clang/tag-e1.34.7/build_tag-e1.34.7_64/bin/lli: error creating EE: No available targets are compatible with this triple, see -version for the available targets.
FAIL: Running the generated program failed!
Traceback (most recent call last):
File "/home/rillingworth/Projects/asm/emscripten/emcc", line 1571, in
final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args)
File "/home/rillingworth/Projects/asm/emscripten/tools/", line 1370, in emscripten
assert os.path.exists(filename + '.o.js') and len(open(filename + '.o.js', 'r').read()) > 0, 'Emscripten failed to generate .js: ' + str(compiler_output)
AssertionError: Emscripten failed to generate .js:

Any ideas why it fails to recognise the object file type?

If you have any other suggestions, I would love to hear them.

Thanks in advance


ps: if you are feeling really generous, could you rerun the process and dump the full output here?
That was I can simply walk through it and find out where mine is going wrong


This comment has been minimized.

Copy link

fiatjaf commented Apr 25, 2017

I tried this. I tried with both the tarball and the git source code. I tried installing Oniguruma and using Oniguruma from modules/oniguruma. I tried precompiling Oniguruma with emscriptem before. I tried moving Oniguruma source code to modules/oniguruma. I tried passing many different directives to emmake make, both the ones specified here and those from jq's readme. All failed.


This comment has been minimized.

Copy link

fiatjaf commented May 5, 2017

Ok, I finally got it working. For all begginers like me, the above instructions do work, but here's what I did exactly:

  1. download the (the full repository) of oniguruma and jq from GitHub.
  2. unzip oniguruma, enter the directory, run autoreconf -i, emconfigure ./configure and emmake make
  3. unzip jq, enter the directory, run autoreconf -i
  4. move your own oniguruma directory (which is probably called "oniguruma-master") to "jq-master/modules/oniguruma" (delete the blank directory that comes inside "jq-master/modules/")
  5. run the instructions above with absolute strictness


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.