openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

The DISPLAY environment variable is missing on RPI4

Open stephanschulz opened this issue 2 years ago • 9 comments

I am on a Raspberry Pi 4 model B with the 32bit version of the OS installed via the Raspberry PI Imager app on macOS 12.

I am trying to compile the videoPlayer example using OF 0.12 and also the latest nightly build of_v20231018_linuxarmv6l_release

In order for it to compile I had to comment out PLATFORM_LIBRARIES += openmaxil as suggested here and here

But I get this error when trying to use make run while SSH in tot he RPI.

[ error ] ofAppGLFWWindow: 65544: X11: The DISPLAY environment variable is missing
[ error ] ofAppGLFWWindow: couldn't init GLFW
[ error ] ofAppGLFWWindow: 65537: The GLFW library is not initialized

When I try make run on the PRI4 directly I get this error:

IMG_6468

stephanschulz avatar Oct 18 '23 17:10 stephanschulz

it is normal if you are invoking via ssh try

DISPLAY=:0 make RunRelease

dimitre avatar Oct 18 '23 19:10 dimitre

or try to run via keyboard / mouse on rpi itself

dimitre avatar Oct 18 '23 19:10 dimitre

the photo is me trying directly via keyboard on the rpi.

stephanschulz avatar Oct 18 '23 19:10 stephanschulz

There are some tips at the end of the setup guide. RPI 4 requires an X environment to run due to changes in their video driver. We're working on a new approach for this but for now X is required.

End of: https://openframeworks.cc/setup/raspberrypi/raspberry-pi-getting-started/

Will paste it here:

Tips for 0.12.0 / Raspberry Pi 4

If you don't want to run PI apps from the X desktop enviornment but want to use the GLFW window system ( or have a Raspberry Pi 4 which requires X ) you can run an OF app without the desktop. First make sure you have X installed with: sudo apt-get install xorg then launch your app with: startx ./polygonExample -- -s off. Your app will run with an X window but without the overhead of the desktop enivornment.

If you want to run an app headless you can use XVFB ( X Virtual Framebuffer ). First install XVFB with: sudo apt-get install xvfb Then run your app with: xvfb-run ./polygonExample &. You won't see a window, but GL operations will be executed. Finally for users who are looking for the old EGL style window support but with Raspberry Pi 4. This work in progress addon is very close to providing similar functionality.

ofTheo avatar Oct 19 '23 15:10 ofTheo

Thank you for taking the time to explain this to me. I did not realize that I thought only if you run the pi without a desktop this would be needed.

Nonetheless. I installed x with sudo apt-get install xorg I cd to the polygonExample and called make and then call startx ./polygonExample -- -s but get errors. see photos below. IMG_6475 IMG_6476

so I also tried rebooting and just calling startx which gives the same errors: IMG_6477

stephanschulz avatar Oct 19 '23 16:10 stephanschulz

since this error message mentioned the /dev/tty0 serial port I disabled anything serial in the config and rebooted.

while this part of the. error message is gone the rest remains.

stephanschulz avatar Oct 19 '23 16:10 stephanschulz

Ahh. I think we've only tested the setup for Pi 4 by installing the Desktop version of Raspbian. You'll definitely need to have startx working for the OF non-desktop hacks to work.

ps: We're hoping to get a better approach soon that uses native display drivers so we don't have to rely on X.

ofTheo avatar Oct 19 '23 17:10 ofTheo

I have been using the desktop 32bit version through out all my tests.

Screen Shot 2023-10-19 at 1 35 34 PM . . Screen Shot 2023-10-19 at 1 46 23 PM

Maybe I should try the 64bit version

Thank you for all you do. I am looking forward to the newer OF version which removes the need for X

stephanschulz avatar Oct 19 '23 17:10 stephanschulz

I had to use sudo startx ./polygonExample -- -s off

my steps

  • 64bit os version with desktop via raspberry pi imager.app

on PI

  • set user name pi and password xxxxx
  • do not update anything during setup process
  • enable SSH via system window
  • download OF (maybe needs to be [latest nightly build](https://github.com/openframeworks/openFrameworks/releases/tag/nightly))

in mac terminal:

  • clear SSH key ssh-keygen -R 192.168.93.156
  • log in to pi via ssh ssh [[email protected]](mailto:[email protected])
  • sudo raspi-config → 6 advanced options → A1 expand …
  • follow [OF install steps](https://openframeworks.cc/setup/raspberrypi/raspberry-pi-getting-started/)
  • i did not run sudo apt-get upgrade
  • cd /home/pi/openFrameworks/scripts/linux/debian
  • sudo ./install_dependencies.sh
  • make Release -C /home/pi/openFrameworks/libs/openFrameworksCompiled/project
  • cd to /home/pi/of_v20231019_linuxaarch64_release/examples/graphics/polygonExample/bin
  • call make
  • sudo startx ./polygonExample -- -s off

stephanschulz avatar Oct 19 '23 19:10 stephanschulz