bsansouci / reprocessing-example

79 stars 29 forks source link

Does not build properly on OpenSUSE 42.2, npm version 5.6.0 #7

Open jdeisenberg opened 6 years ago

jdeisenberg commented 6 years ago
david@linux:~/reasonlab> git clone https://github.com/bsansouci/reprocessing-example.git
Cloning into 'reprocessing-example'...
remote: Counting objects: 151, done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 151 (delta 19), reused 20 (delta 9), pack-reused 107
Receiving objects: 100% (151/151), 476.05 KiB | 0 bytes/s, done.
Resolving deltas: 100% (69/69), done.
david@linux:~/reasonlab> cd reprocessing-example
david@linux:~/reasonlab/reprocessing-example> npm install

> sdl2@2.0.5 postinstall /home/david/reasonlab/reprocessing-example/node_modules/sdl2
> node postinstall.js

No pre-built binaries for linux, downloading source
Unzip successful.                          
Building from source, will take a minute or two.
Looks like SDL2 built successfully.

> bs-platform@2.1.1 postinstall /home/david/reasonlab/reprocessing-example/node_modules/bs-platform
> node postinstall.js

Unzip successful.                            
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN reprocessing-example@ No repository field.
npm WARN reprocessing-example@ No license field.

added 11 packages in 105.306s
david@linux:~/reasonlab/reprocessing-example> npm run build

> reprocessing-example@ build /home/david/reasonlab/reprocessing-example
> bsb -make-world

[2/2] Building fake_src/sdl_index.mlast.d
[2/2] Building lib.cma
[4/4] Building run_build_script
[3/3] Building lib.cma
[4/4] Building run_build_script
[3/3] Building lib.cma
[18/18] Building run_build_script
[8/10] Building src/native/reasongl_native.cmo

  Warning number 27
  /home/david/reasonlab/reprocessing-example/node_modules/Reasongl/src/native/reasongl_native.re 121:17-25

  119 ┆  * osx will give us and one that has an API comparable to OpenGL ES 2
        .0 which is what WebGL uses.
  120 ┆  */
  121 ┆ let init = (~screen=?, ~argv as _) => {
  122 ┆   /* Screen is ignored for now, we always just create a new window. *
        /
  123 ┆   if (Sdl.Init.init(Sdl.Init.video lor Sdl.Init.audio) != 0) {

  unused variable screen.
[10/10] Building lib.cma
[42/42] Building src/Reprocessing_Internal.mlast.d
[22/22] Building lib.cma
ninja: Entering directory `lib/bs/bytecode'
[4/4] Building src/index.mlast.d
[3/3] Building indexhot.byte
FAILED: indexhot.byte 
/home/david/reasonlab/reprocessing-example/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/reasonlab/reprocessing-example/node_modules/Reasongl/lib/reasongl.o -add-clib /home/david/reasonlab/reprocessing-example/node_modules/Tgls/lib/glad.o -add-clib /home/david/reasonlab/reprocessing-example/node_modules/Tgls/lib/image_helper.o -add-clib /home/david/reasonlab/reprocessing-example/node_modules/Tgls/lib/stb_image_aug.o -add-clib /home/david/reasonlab/reprocessing-example/node_modules/Tgls/lib/image_DXT.o -add-clib /home/david/reasonlab/reprocessing-example/node_modules/Tgls/lib/SOIL.o -add-clib /home/david/reasonlab/reprocessing-example/node_modules/Tgls/lib/soil_wrapper.o -add-clib /home/david/reasonlab/reprocessing-example/node_modules/Tgls/lib/tgls_new.o -add-clib /home/david/reasonlab/reprocessing-example/node_modules/Tsdl/lib/tsdl_new.o -add-clib /home/david/reasonlab/reprocessing-example/node_modules/sdl2/libSDL2.a  -I /home/david/reasonlab/reprocessing-example/node_modules/sdl2/lib/ocaml/bytecode -I /home/david/reasonlab/reprocessing-example/node_modules/Tsdl/lib/ocaml/bytecode -I /home/david/reasonlab/reprocessing-example/node_modules/Tgls/lib/ocaml/bytecode -I /home/david/reasonlab/reprocessing-example/node_modules/Reasongl/lib/ocaml/bytecode -I /home/david/reasonlab/reprocessing-example/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.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! reprocessing-example@ build: `bsb -make-world`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the reprocessing-example@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/david/.npm/_logs/2018-04-12T14_31_59_856Z-debug.log
david@linux:~/reasonlab/reprocessing-example> 
bsansouci commented 6 years ago

Hey @jdeisenberg thanks for opening this issue. This looks very similar to https://github.com/Schmavery/reprocessing/issues/72

Could you show me cat node_modules/sdl2/sdl2.pc and cat node_modules/sdl2/bsconfig.json?

This is because we kinda generate the same linking flags for all versions of linux, disregarding what the ./configure generated inside the sdl2.pc (which contains exactly the right flags for your distro). See https://github.com/bsansouci/SDL-mirror/blob/129e47282cc72b7d51246b18a4da48d919799092/postinstall.js#L135.

So eh... the real fix would be to regex parse the sdl2.pc file and generate a more correct bsconfig than this ^.

jdeisenberg commented 6 years ago
> cat node_modules/sdl2/sdl2.pc
# sdl pkg-config source file

prefix=/home/david/reasonlab/reprocessing-example/node_modules/sdl2
exec_prefix=${prefix}
libdir=/home/david/reasonlab/reprocessing-example/node_modules/sdl2
includedir=${prefix}/include

Name: sdl2
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
Version: 2.0.5
Requires:
Conflicts:
Libs: -L${libdir} -Wl,-rpath,${libdir} -Wl,--enable-new-dtags -lSDL2 
Libs.private: -lSDL2   -Wl,--no-undefined -lm -ldl -lpthread -lrt
Cflags: -I${includedir}/SDL2   -D_REENTRANT

> cat node_modules/sdl2/bsconfig.json
{
  "name": "sdl2",
  "sources": "fake_src",
  "c-linker-flags": ["-lasound", "-lm", "-ldl", "-lpthread", "-lrt"],
  "static-libraries": ["libSDL2.a"],
  "allowed-build-kinds": ["bytecode", "native"],
  "refmt": 3,
}
Schmavery commented 6 years ago

@jdeisenberg I think this is similar to the fix here: https://github.com/bsansouci/SDL-mirror/pull/2 by @zploskey (which was the solution to the issue ben mentioned) , where we had some unnecessary dependencies specified. By looking at a couple of pkg-configs including yours, it seems like nothing actually requires -lasound to be statically linked anymore and we can remove this flag. Feel free to try removing -lasound from your sdl2 bsconfig.json and see if that helps it build.