node-raylib icon indicating copy to clipboard operation
node-raylib copied to clipboard

using node-raylib on raspbery pi

Open daniel-thd-labs opened this issue 5 years ago • 12 comments

Hi We are currently using node js on a raspberry pi project. I'm trying to install/use node-raylib to build a GUI displayed in a 5" hdmi screen. I'm using the commands from the "usage" section from the readme.md I'm getting acces errors on the <sudo npm install raylib --save> command (see pdf doc) I would want to know if it is possible to port the existing gitgub pull as indicated on the web page. Any help making this work would be great thanks! dbmdbu node-raylib_to_raspberrypi.pdf

daniel-thd-labs avatar Apr 16 '20 17:04 daniel-thd-labs

Looks like you got some permission errors. You shouldn't really need to run with sudo.

RobLoach avatar Apr 16 '20 18:04 RobLoach

Hi Rob Regarding the Node-raylib to raspbery pi install issues, I fixed some of them as hey were caused by the /dev/root being saturated, ("df -h" showing /dev/root/ at 100%).

Did a fresh ""rasbian-buster-lite".img" re-install to a larger SD card. I'm getting "deeper" in the install process but still not to a 100% completion.

This is what I did so far: New rasbian-buster-lite image (expand drive partition) installed: GIT (tested, working ok) installed: node (V12.6.2 tested, working ok) installed: npm (V6.14.4 tested, working ok) installed: cmake installed: raylib from GIT clone and compiled code and examples installed: node-raylib from GIT clone...

A few questions, from the usage section: npm init:

  • from what directory should It be called?
  • What should be filled in the requested fields?

npm install raylib --save:

  • from what directory should It be called?

Getting "post install" cmake-js compile errors messages. this is the error messages I get on this step npm_install_nod_raylib_log.pdf

Any pointers would be appreciated Daniel

daniel-thd-labs avatar Apr 19 '20 15:04 daniel-thd-labs

The simple_game template provides a small example...

cd templates/simple_game
npm install
npm test

RobLoach avatar Apr 19 '20 16:04 RobLoach

Hi Rob

As I kept having the the same results with the "simple game", so I tested the process on my Mac computer (running High Sierra), using the following steps:

  1. installed: Node +npm (from installer)
  2. installed brew (>/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. cloned raylib git (>git clone https://github.com/raysan5/raylib.git)
  4. make raylib library: (from raylib/src --> make PLATFORM=PLATFORM_DESKTOP)
  5. make raylib examples: (from raylib/examples --> make PLATFORM=PLATFORM_DESKTOP)
  6. test a few raylib examples, it works!
  7. install node-raylib (>npm install raylib --save)
  8. create a node "test.js" file using the "core_basic_window.js" file from node-raylib example (
  9. run the "test.js" code (>node test.js)

And voilà! it works.

Now to get it working on a raspberry pi: The errors I get seem to be related to something in the (">cmake-js compile") phase (see "CMakeLists.txt" warning) ============================================

This is what I get: pi@tai:~ $ npm install raylib --save npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142

[email protected] postinstall /home/pi/node_modules/raylib cmake-js compile

[ '/usr/bin/node', '/home/pi/node_modules/.bin/cmake-js', 'compile' ] info TOOL Using Unix Makefiles generator. info DIST Downloading distribution files. http DIST - https://nodejs.org/dist/v12.16.2/SHASUMS256.txt http DIST - https://nodejs.org/dist/v12.16.2/node-v12.16.2-headers.tar.gz info CMD CONFIGURE info RUN cmake "/home/pi/node_modules/raylib" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="6.1.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/home/pi/node_modules/raylib/build/Release" -DCMAKE_JS_INC="/home/pi/.cmake-js/node-arm/v12.16.2/include/node" -DCMAKE_JS_SRC="" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="12.16.2" -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 CMake Warning at CMakeLists.txt:24 (find_package): By not providing "Findraylib.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "raylib", but CMake did not find one.

Could not find a package configuration file provided by "raylib" (requested version 3.0.0) with any of the following names:

raylibConfig.cmake
raylib-config.cmake

Add the installation prefix of "raylib" to CMAKE_PREFIX_PATH or set "raylib_DIR" to a directory containing one of the above files. If "raylib" provides a separate development package or SDK, be sure it has been installed._

As a reference for compare, this is what I got from the OSx install:

imac-maison:~ admin$ npm install raylib --save npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142

[email protected] postinstall /Users/admin/node_modules/raylib cmake-js compile

[ '/usr/local/bin/node', '/Users/admin/node_modules/.bin/cmake-js', 'compile' ] info TOOL Using Unix Makefiles generator. info CMD CONFIGURE info RUN cmake "/Users/admin/node_modules/raylib" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="6.1.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/Users/admin/node_modules/raylib/build/Release" -DCMAKE_JS_INC="/Users/admin/.cmake-js/node-x64/v12.16.2/include/node" -DCMAKE_JS_SRC="" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="12.16.2" -DNODE_ARCH="x64" -DCMAKE_CXX_FLAGS="-D_DARWIN_USE_64_BIT_INODE=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DBUILDING_NODE_EXTENSION" -DCMAKE_SHARED_LINKER_FLAGS="-undefined dynamic_lookup" Not searching for unused variables given on the command line. -- The C compiler identification is AppleClang 10.0.0.10001044 -- The CXX compiler identification is AppleClang 10.0.0.10001044 -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- Check for working C compiler: /Library/Developer/CommandLineTools/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: /Library/Developer/CommandLineTools/usr/bin/c++ -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found raylib: /usr/local/Cellar/raylib/3.0.0/lib/libraylib.dylib (Required is at least version "3.0.0") -- Configuring done -- Generating done -- Build files have been written to: /Users/admin/node_modules/raylib/build info CMD BUILD info RUN cmake --build "/Users/admin/node_modules/raylib/build" --config Release Scanning dependencies of target node-raylib [ 50%] Building CXX object CMakeFiles/node-raylib.dir/src/addon.cc.o [100%] Linking CXX shared library Release/node-raylib.node [100%] Built target node-raylib npm WARN [email protected] No description npm WARN [email protected] No repository field.

  • [email protected] updated 1 package and audited 287 packages in 46.229s found 0 vulnerabilities

Daniel Benoit

daniel-thd-labs avatar Apr 22 '20 14:04 daniel-thd-labs

It compiled and ran on RPI??!?!?!?

RobLoach avatar Apr 22 '20 17:04 RobLoach

Is it a question? or you have tried it and it works? For me I get this message: CMake_ Warning at CMakeLists.txt:24 (find_package): By_ not providing "Findraylib.cmake" in CMAKE_MODULE_PATH this project has asked_ CMake to find a package configuration file provided by "raylib", but CMake did not find one.

Could not find a package configuration file provided by "raylib" (requested version 3.0.0) with any of the following names:

daniel-thd-labs avatar Apr 22 '20 20:04 daniel-thd-labs

and it doesn't work...

daniel-thd-labs avatar Apr 22 '20 20:04 daniel-thd-labs

That's a warning saying it couldn't find an already existing version of Raylib, so it'll build it.

Going to reopen this for now. Thanks!

RobLoach avatar Apr 22 '20 21:04 RobLoach

We somehow need to pass PLATFORM="Raspberry Pi" to cmake-js.

RobLoach avatar Apr 23 '20 15:04 RobLoach

I started using raylib on a raspberry pi in C, building my own C++ classes to represent certain elements. But I have a data source that I heavily use that supplies JSON data, which is a pain to work with in C because the types are not very reliable, so If this binding actually works flawlessly on a Raspberry Pi, I would be incredibly happy. I'd actually start over. Please let me know if I can by of any help. I'll try on my own if I can get this to run tomorrow. I guess getting cmake to behave correctly is the main issue here.

armageddon421 avatar Apr 24 '20 22:04 armageddon421

Have a few options for JSON and c....

  • https://github.com/kgabis/parson
  • https://github.com/sheredom/json.h
  • https://github.com/json-c/json-c

RobLoach avatar Apr 25 '20 06:04 RobLoach

Hi Rob

In a previous post, you said: We somehow need to pass PLATFORM="Raspberry Pi" to cmake-js.

I have been trying to pass or force <PLATFORM="Raspberry Pi"> in many ways without any success. I managed to modify the raylib CMakefile.txt and Makefile files so it could build to Raspberry pi(OpenGL ES 2.0 in native mode) without having to call >make PLATFORM=Raspberry Pi.

Being experienced in the low level embedded code domain (not in the world of npm/make/cmake/cmake-js ), I cant really efficiently see how to override the install/patch the >npm raylib process.

That's a warning saying it couldn't find an already existing version of Raylib, so it'll build it.

Is there a way to tell raylib is already installed and built to "RPI native mode" and not rebuild it. Any pointer would be appreciated

Daniel Benoit

daniel-thd-labs avatar Apr 27 '20 14:04 daniel-thd-labs