RobLoach / node-raylib

Node.js bindings for Raylib
https://robloach.github.io/node-raylib/
Other
242 stars 20 forks source link

Build doesn't support OpenGL ES 2.0 in native mode #34

Open mattsains opened 5 years ago

mattsains commented 5 years ago

For systems that don't have an x11 installation, the raylib library supports the "OpenGL ES 2.0 in native mode":

make PLATFORM=PLATFORM_RPI && make install

However, running npm install raylib doesn't work if you don't have an x11 install:

npm install raylib

> raylib@0.1.1 postinstall /home/pi/smartclock/node_modules/raylib
> cmake-js compile

[ '/usr/local/bin/node',
  '/home/pi/smartclock/node_modules/.bin/cmake-js',
  'compile' ]
info TOOL Using Unix Makefiles generator.
info CMD CONFIGURE
info RUN cmake "/home/pi/smartclock/node_modules/raylib" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="5.3.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/home/pi/smartclock/node_modules/raylib/build/Release" -DCMAKE_JS_INC="/home/pi/.cmake-js/node-arm/v11.15.0/include/node" -DCMAKE_JS_SRC="" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="11.15.0" -DNODE_ARCH="arm"
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Populating raylib
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/smartclock/node_modules/raylib/build/_deps/raylib-subbuild
Scanning dependencies of target raylib-populate
[ 11%] Creating directories for 'raylib-populate'
[ 22%] Performing download step (git clone) for 'raylib-populate'
Cloning into 'raylib-src'...
Checking out files: 100% (1001/1001), done.
Note: checking out 'a43d49ed72f41dddb5e71c26aa981076fe26f1f5'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at a43d49ed Added CMake flags
[ 33%] No patch step for 'raylib-populate'
[ 44%] Performing update step for 'raylib-populate'
[ 55%] No configure step for 'raylib-populate'
[ 66%] No build step for 'raylib-populate'
[ 77%] No install step for 'raylib-populate'
[ 88%] No test step for 'raylib-populate'
[100%] Completed 'raylib-populate'
[100%] Built target raylib-populate
-- Performing Test COMPILER_HAS_THOSE_TOGGLES
-- Performing Test COMPILER_HAS_THOSE_TOGGLES - Success
-- Testing if -Werror=pointer-arith can be used -- compiles
-- Testing if -Werror=implicit-function-declaration can be used -- compiles
-- Testing if -fno-strict-aliasing can be used -- compiles
-- Testing if file system supports symlinks
-- Testing if file system supports symlinks -- supported
-- Using raylib's GLFW
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Using X11 for window creation
CMake Error at /usr/share/cmake-3.13/Modules/FindX11.cmake:429 (message):
  Could not find X11
Call Stack (most recent call first):
  build/_deps/raylib-src/src/external/glfw/CMakeLists.txt:205 (find_package)

-- Configuring incomplete, errors occurred!

It would be nice if the cmake file could use the lack of x11 to infer that raylib needs to be built without x11 support.

As an alternative, I have already installed the raylib binaries, so maybe the node library could look for the raylib library (eg., by calling ld -lraylib) and just use the existing on present in the system.

mattsains commented 5 years ago

I discovered that this error is coming from running cmake on raylib, here: https://github.com/raysan5/raylib/blob/4d8b9e595a62e094b840a15efc1d7710128aa1f4/src/external/glfw/CMakeLists.txt#L159

I think this implies that the cmake script in this package isn't finding my raylib install here: https://github.com/RobLoach/node-raylib/blob/master/CMakeLists.txt#L12

I don't know how this is looking for the library, since it's definitely installed - I can run ld -lraylib and it returns "ld: warning: cannot find entry symbol _start; defaulting to 00010034"

mattsains commented 5 years ago

I read https://github.com/raysan5/raylib/issues/813 and it looks like I might be missing a cmake library that was supposed to be copied to my system during make install of raylib.

I'm not sure where this is supposed to be located though.

I think it's possible that the instructions I followed to install cmake on my Raspberry Pi might be incomplete, but I'm not sure how https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi#user-content-compiling-raylib-source-code

One thing that isn't listed there that I did was running make install afterward.

RobLoach commented 5 years ago

Thanks for checking it out... Interesting. I'm not quite sure how to switch how raylib would compile.

https://www.npmjs.com/package/cmake-js

There's some opts in there we could inject.

acklavidian commented 4 years ago

I have been trying to accomplish this myself for the past few days. @RobLoach is there some way I could edit the repo's root CmakeList.txt? I have successfully compiled on my machine with: make PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_21.

RobLoach commented 4 years ago

For sure! Would love to make the build a bit more dynamic in it's compilation.

acklavidian commented 4 years ago

I meant to ask you how to do this. I don't know much about cmake. I just know that the default raylib repo compiles without any error with those args given to make. Not sure how to adjust that for cmake in this repo.

RobLoach commented 4 years ago

I'm sure Node.js is available for raspberry pi, but I'm unsure how exactly. It should be something in the "cmake-js" options...

{
  "name": "ta-taram-taram",
  "description": "pa-param-pam-pam",
  "version": "1.0.0",
  "main": "app.js",
  "cmake-js": {
    "runtime": "node",
    "runtimeVersion": "0.12.0",
    "arch": "arm"
  }
}
cmake-js compile --CDPLATFORM="PLATFORM_RPI"

Something like that?