Schmavery / reprocessing

ReasonML graphics library inspired by Processing
https://schmavery.github.io/reprocessing/
MIT License
682 stars 24 forks source link

"Error while building custom runtime system" when building a sample program #93

Open jdeisenberg opened 6 years ago

jdeisenberg commented 6 years ago

Cloned https://github.com/codekiln/reasonml-playground and went to the reprocessing01 directory, did npm install then ./node_modules/.bin/bsb -make-world and got the following output:

david@linux:~/reasonml-playground/reprocessing01> ./node_modules/.bin/bsb -make-world
ninja: no work to do.
[1/1] Building run_build_script
[1/1] Building run_build_script
[1/1] Building run_build_script
[1/1] Building run_build_script
[1/1] Building run_build_script
[1/1] Building run_build_script
ninja: no work to do.
ninja: Entering directory `lib/bs/bytecode'
[1/1] Building indexhot.byte
FAILED: indexhot.byte 
/home/david/reasonml-playground/reprocessing01/node_modules/bs-platform/lib/bsb_helper.exe  -add-ocaml-dependency bigarray -add-ocaml-dependency dynlink -add-ocaml-dependency nums -add-ocaml-dependency str -add-ocaml-dependency threads -add-ocaml-dependency unix -w -30-40+6+7+27+32..39+44+45+101  -bs-main IndexHot -bs-super-errors -add-clib -ccopt -add-clib -lasound -add-clib -ccopt -add-clib -lm -add-clib -ccopt -add-clib -ldl -add-clib -ccopt -add-clib -lpthread -add-clib -ccopt -add-clib -lrt -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/Reasongl/lib/reasongl.o -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/Tgls/lib/glad.o -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/Tgls/lib/image_helper.o -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/Tgls/lib/stb_image_aug.o -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/Tgls/lib/image_DXT.o -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/Tgls/lib/SOIL.o -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/Tgls/lib/soil_wrapper.o -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/Tgls/lib/tgls_new.o -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/Tsdl/lib/tsdl_new.o -add-clib /home/david/reasonml-playground/reprocessing01/node_modules/sdl2/libSDL2.a  -I /home/david/reasonml-playground/reprocessing01/node_modules/sdl2/lib/ocaml/bytecode -I /home/david/reasonml-playground/reprocessing01/node_modules/Tsdl/lib/ocaml/bytecode -I /home/david/reasonml-playground/reprocessing01/node_modules/Tgls/lib/ocaml/bytecode -I /home/david/reasonml-playground/reprocessing01/node_modules/Reasongl/lib/ocaml/bytecode -I /home/david/reasonml-playground/reprocessing01/node_modules/Reprocessing/lib/ocaml/bytecode src/IndexHot.mlast src/index.mlast -link-bytecode indexhot.byte
/usr/lib64/gcc/x86_64-suse-linux/5/../../../../x86_64-suse-linux/bin/ld: cannot find -lasound
collect2: error: ld returned 1 exit status

  We've found a bug for you!
  (No file name)

  Error while building custom runtime system

ninja: build stopped: subcommand failed.

Files in node_modules directory:

bs-platform   fd-slicer  pend      Reprocessing  Tgls  yauzl
buffer-crc32  gl-matrix  Reasongl  sdl2          Tsdl
Schmavery commented 6 years ago

Ah ok, this looks like this issue: https://github.com/bsansouci/reprocessing-example/issues/7 Sorry we didn't get around to fixing it! haha

Do you mind trying to edit your node_modules/sdl2/postinstall.js at line 135:

platformspecificargs = `"-lasound", "-lm", "-ldl", "-lpthread", "-lrt"`

and remove the "-lasound", like so:

platformspecificargs = `"-lm", "-ldl", "-lpthread", "-lrt"`

and then try to bsb -clean-world and bsb -make-world?

If that works, we should be able to just remove that from master and you should be good to go :)

Schmavery commented 6 years ago

If this doesn't work, we'll probably need to add a note to the README for people with this issue to sudo apt install libasound2-dev or similar, but I'd love to avoid that if we can :)

As usual, we apologize for the flakiness of our linux support and greatly appreciate the troubleshooting help :)

jdeisenberg commented 6 years ago

Still has a problem:

david@linux:~/reasonml-playground/reprocessing01> bsb -clean-world
ninja: error: loading 'build.ninja': No such file or directory
ninja clean failed
ninja: error: loading 'build.ninja': No such file or directory
ninja clean failed
ninja: error: loading 'build.ninja': No such file or directory
ninja clean failed
ninja: error: loading 'build.ninja': No such file or directory
ninja clean failed
ninja: error: loading 'build.ninja': No such file or directory
ninja clean failed
ninja: error: loading 'build.ninja': No such file or directory
ninja clean failed
david@linux:~/reasonml-playground/reprocessing01> bsb -make-world
[2/2] Building fake_src/sdl_index.mlast.d
[1/1] Building fake_src/sdl_index.cmj
[2/2] Building src/tsdl_new.mlast.d
[1/1] Building src/tsdl_new.cmj
FAILED: src/tsdl_new.cmj /home/david/reasonml-playground/reprocessing01/node_modules/Tsdl/lib/js/src/tsdl_new.js src/tsdl_new.cmi 
/home/david/.nvm/versions/node/v10.1.0/lib/node_modules/bs-platform/lib/bsc.exe -bs-package-name Tsdl  -bs-package-output commonjs:lib/js/src -bs-assume-no-mli -bs-no-builtin-ppx-ml -bs-no-implicit-include -I /home/david/reasonml-playground/reprocessing01/node_modules/sdl2/lib/ocaml -I src  -w -30-40+6+7+27+32..39+44+45+101 -nostdlib -I '/home/david/reasonml-playground/reprocessing01/node_modules/bs-platform/lib/ocaml' -no-alias-deps -color always -bs-re-out -bs-super-errors -o src/tsdl_new.cmj -c  src/tsdl_new.mlast 
ninja: build stopped: subcommand failed.
Failure: /home/david/.nvm/versions/node/v10.1.0/lib/node_modules/bs-platform/lib/ninja.exe 
 Location: /home/david/reasonml-playground/reprocessing01/node_modules/Tsdl/lib/bs

(Also, my version of OpenSUSE doesn’t appear to have libasound2-dev or its equivalent)

Schmavery commented 6 years ago

Sorry, I should have been clearer with the commands, if you have a global bs-platform install, bsb -make-world is going to be using that instead of the (bsb-native) local one. Does npm run clean followed by npm run build work any better?

jdeisenberg commented 6 years ago

./node_modules/.bin/bsb -make-world seems to have worked (after npm run clean) -- at least there are no errors, but there is no lib/js directory, which index.html seems to want [further edit: I need to do npm build:web]

Schmavery commented 6 years ago

@jdeisenberg so it sounds like removing that -lasound flag fixed your problem (once you built using the local bsb)? If so I'll remove it in https://github.com/bsansouci/SDL-mirror/blob/fast/postinstall.js#L135 and hopefully we'll be able to take care of this issue for good 😄

Yeah, with bsb-native you specify whether you want to build to native/bytecode or to js separately. Since the first "target" in the bsconfig.json is a bytecode target, it defaults to that if you don't specify a backend (like what the npm build:web script does).

jdeisenberg commented 6 years ago

When trying to load the index.html file in the browser from File > Open menu, I get these errors in the web console:

XML Parsing Error: not well-formed
Location: file:///home/david/reasonml-playground/reprocessing01/lib/js/src/index.js
Line Number 1, Column 1: index.js:1:1
Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead[Learn More] require_polyfill.js:82
XML Parsing Error: not well-formed
Location: file:///home/david/reasonml-playground/reprocessing01/node_modules/Reprocessing/lib/js/src/Reprocessing.js
Line Number 1, Column 1: Reprocessing.js:1:1
Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead[Learn More] require_polyfill.js:368
XML Parsing Error: not well-formed
Location: file:///home/david/reasonml-playground/reprocessing01/node_modules/bs-platform/lib/js/sys.js
Line Number 1, Column 13: sys.js:1:13 
[[ snip many repetitions]]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///home/david/reasonml-playground/reprocessing01/node_modules/Reasongl/lib/js/src/RGLConstants.js. (Reason: CORS request not http).

The last error tells me that I have to run the code from a server (cross-site scripting error), so I did that, and get this set of errors:

Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead[Learn More] require_polyfill.js:82
Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead[Learn More] require_polyfill.js:368

[[snip many similar errors]]

SyntaxError: expected expression, got '<'[Learn More] require_polyfill.js:48
loadScript
http://roombook.evc.test/reprocessing01/require_polyfill.js:146:10
require node_modules/Reprocessing/lib/js/src/Reprocessing.js:36:18 <anonymous> node_modules/Reprocessing/lib/js/src/Reprocessing.js:55:34 loadScript
http://roombook.evc.test/reprocessing01/require_polyfill.js:146:10
require lib/js/src/index.js:36:18 <anonymous> lib/js/src/index.js:51:30 loadScript
http://roombook.evc.test/reprocessing01/require_polyfill.js:146:10
<anonymous>
http://roombook.evc.test/reprocessing01/require_polyfill.js:149:1
Schmavery commented 6 years ago

@jdeisenberg the issue you were originally experiencing should have nothing to do with the web build of reprocessing and should only occur when building to native or bytecode. You can try running npm run start or ./lib/bs/bytecode/indexhot.byte to test after running npm run build or ./node_modules/.bin/bsb -make-world

I'm not sure what's going on in your web build, seems like maybe require_polyfill is getting confused somehow. Can you share what browser you're using and how you're running the server? To test, we frequently just use python -m SimpleHTTPServer or similar. @bsansouci have you seen this before?

jdeisenberg commented 6 years ago

npm run start appeared to work nicely.

I am using Server version: Apache/2.4.23 (Linux/SUSE), testing on browsers: Firefox Developer Edition 61.0b6 (64-bit) and Version 66.0.3359.170 (Official Build) (64-bit)

bsansouci commented 6 years ago

Mmmh weird, why is the -lasound still there? https://github.com/bsansouci/SDL-mirror/blob/eb7279c6f7235ca03b40775b64de7f04ed29fdfc/postinstall.js#L21

Schmavery commented 6 years ago

@bsansouci I think you were looking at the wrong branch ;P

As far as the web errors, I don't know much about the inner workings of require-polyfill, it's possible it has some issues under certain scenarios. The python server has worked for us in the past. Maybe there's some issue with the setup of that project? @codekiln have you had any problems running on web?

codekiln commented 6 years ago

I've only done a few examples for web, and they have all worked.