Juce on the Raspberry Pi & OpenGL?


#1

Hi Everyone,

I’ve been compiling some Juce projects for the Raspberry Pi.

Juce apps will compile under Raspbian as follows:

(1) get the following updates (thanks to the thread that posted this list!)

sudo apt-get -y install libfreetype6-dev sudo apt-get -y install libx11-dev sudo apt-get -y install libxinerama-dev sudo apt-get -y install libxcursor-dev sudo apt-get -y install mesa-common-dev sudo apt-get -y install libasound2-dev sudo apt-get -y install freeglut3-dev sudo apt-get -y install libxcomposite-dev sudo apt-get -y install libjack-dev

(2) Have Introjucer generate the Linux target

(3) change the linux Makefile to say

[NB: can also change the CONFIG to Release default here]

(4) JuceLibraryCode/AppConfig.h

(5) modules/juce_gui_basics/juce_gui_basics.h

(steps 4 & 5 might not be necessary).

Ok, so my question is; does anyone have any idea if OpenGL ES 2.0 can be made to work. Apparently, there is/was a problem using OpenGL under X on the PI - is this still true or is it fixed?

mysteriously my OGL program links with the generated makefile. it crashes though! The default makefile doesn’t link with any GL libs. This seems a mystery to me. should I be static linking to OGL, or is there no chance of it working?

any ideas.
– hugh.


#2

I am working on a Python API to OpenGL ES 2.0 called pi3d and we’re getting that library to work from Python, so I know it is possible.

Thanks for this excellent information about how to compile Juce on the RP, I’m really psyched to do some work for it…!


#3

Just a followup - I wrote a simple little Juce program on the Mac, compiled it onto the Raspberry Pi using your instructions - and it worked right the first time!

It’d be love to have some “subswitch” someone in the Introjucer so I didn’t have to keep making those last few edits every time I updated, but I’d still say I’m “extremely satisfied” with the results.


#4

Cool stuff. You know that in at the top of the AppConfig.h file there’s a “user code” section where you can put #defines like this, and the introjucer won’t overwrite them?


#5

So then it’s just that -march=armv6 flag…!


#6

Like this, perhaps?


#7

That looks like a good mod. Perhaps with a v7 as well?


#8

#9

I note with pleasure that you have in fact added support for ARM v6 and ARM v7 to the Introjucer. I’m going to rebuild all my Juce stuff from scratch with this new mod, and see if I can in fact get to an executable without any tweaking (my theory - absolutely), and if so, make an announcement on the Juce boards.


#10

So it almost works. :smiley:

The Makefile is basically correct - it does create the right flags but then it overrides them here. If you comment those three lines out, the build seems to move forward… or even just invoke make as


#11

Ok, I’ve rearranged the makefile a bit - try again now…


#12

On it!

While I’m doing that, take a look at this document describing the build process. (I’ll change the “make” command as soon as I’ve tested it.)

Is this good? I’ll send it out to the usual places, if so…


#13

It now works perfectly, and I updated the document to reflect that you can just type “make”.


#14

This is great, have an untouched Pi so will definitely try this out. Do you guys recommend the Getting Started pdf on raspberrypi.org for OS install and whatnot? Favourite Pi baking tips welcome :slight_smile:


#15

I just installed Raspbian and it all seemed to work out of the box.

Don’t forget to apt-get update and apt-get upgrade…! In fact, here’s a script to update, upgrade and update your firmware…


#16

Yippee! (ish)

I recently upgraded  / updated my Pi's OS (sudo apt-get dist-upgrade) and fetched the latest firmware (sudo rpi-update)

I went through each .jucer configuration  Linux Makefile->Extra Preprocessor Definitions adding JUCE_USE_XINERAMA=0  and setting module Juce_gui_basics JUCE_USE_XSHM to Disabled

Rebuilt all of the Juce extras projects (both release and debug, just in case)

{details elsewhere on this forum http://www.juce.com/forum/topic/list-juce-dependancies-under-ubuntu-linux about developing for the pi (I'm using Raspbian http://www.raspbian.org/ rather than anything else )  and about exports  http://www.juce.com/comment/289404#comment-289404 I use } - The build took a while (6-8hrs! with and un-overclocked pi with an 8GB Class 10 SD card )

Then, I made a really fresh pot of tea, and tried it all out ;)

Audio demos (which used to work), now fail :( TBH, when they worked in the past everything was ridiculously slow (and things seemed to report lots of (32) audio chanels!) - but OpenGL demos (which used to fail), now work, albeit v.e.r.y....s.l.o.w.l.y, but flawlessly. Using the frame-count texture, it was clear that screen refresh is the problem (counts jump by the 100's!)  I suspect the audio and graphic slowness are related, but I can't think of way to narrow-down the causes.

I've seen Minecraft running much more rapidly/smoothly, and if I had to guess, I think there's something stll not quite right going on. ).

I found if I left JUCE_USE_XSHM as default & JUCE_USE_XINERAMA=1, the things only worked via VNC (YMMD / OpenGL demos still fail under VNC)

Still, pretty amazing stuff. 

 

Thanks, Jules (and all who contributed) for some stirling work!

 


#17

Just trying out Juce on my RPi (I have one of the original Model Bs). These instructions no longer work out of the box. You need to update to g++4.7 for C++11 support:

http://www.raspberrypi.org/forums/viewtopic.php?f=33&t=22938

And I kept getting this error on 'make' with the default arch setting (native) or specifically arm6:

error: target CPU does not support ARM mode

I just removed these lines from the makefile in both the Debug and Release sections:

  ifeq ($(TARGET_ARCH),)
    TARGET_ARCH := -march=native
  endif

Not sure what a better alternative is.

 


#18

Hi Martin et all,

these are my current notes regarding JUCE on a Raspberry Pi B+. I don't need to modify the JUCE Makefile.

.. author: Samuel Gaehwiler (klangfreund.com)

***************
Raspberry Pi B+
***************


On OSX
======

If you intend to work with the Cirrus Logic Audio Card, download the Raspbian Image from
http://www.element14.com/community/community/raspberry-pi/raspberry-pi-accessories/cirrus_logic_audio_card -> Firmware Download.

Format the microSD card using the SDFormatter https://www.sdcard.org/downloads/formatter_4/ .
Choose "Quick Format".
Call the Card "RECOVERY" (It would be renamed to this from the Raspberry Pi anyways).
(Source: http://www.raspberrypi.org/help/noobs-setup/)

Ensure that disk4 really corresponds to the microSD card::
    diskutil info /Volumes/RECOVERY/

In Disk Utility, unmount the RECOVERY disk. (don't eject in Finder.)

Copy the img (7.34GB) to the microSD card::
    sudo dd bs=1m if=cirrus_audio.img of=/dev/disk4
(Source: http://www.instantsupportsite.com/self-help/raspberry-pi/raspberry-p-wheezy-installation/)
bs = blocksize
This took 3112 seconds to complete... (next time, check if dd has a -v / --verbose flag)

 

On the Raspberry Pi
===================

Blank Screen
------------

If your display remains blank, you should select the correct output mode for your display by pressing one of the following number keys on your keyboard:
1. HDMI mode - this is the default display mode.
2. HDMI safe mode - select this mode if you are using the HDMI connector and cannot see anything on screen when the Pi has booted.
3. Composite PAL mode - select either this mode or composite NTSC mode if you are using the composite RCA video connector.
4. Composite NTSC mode
(Source: INSTRUCTIONS-README.txt)

What did it for me: Reset the display.


Dvorak keyboard layout
----------------------

sudo dpkg-reconfigure keyboard-configuration

Choose the generic keyboard

Choose Dvorak (international with dead keys)

Reboot

(Source: http://www.raspberrypi.org/forums/viewtopic.php?f=27&t=12860 )


Essentials
----------

sudo apt-get install vim

 

JUCE
====


Get JUCE
--------

git clone --depth 1 git://github.com/julianstorer/JUCE.git


Dependencies needed by JUCE
---------------------------

sudo apt-get -y install g++ libfreetype6-dev libx11-dev libxinerama-dev libxcursor-dev mesa-common-dev libasound2-dev freeglut3-dev libxcomposite-dev libjack-dev


Ugrade g++ to support C++11
---------------------------

# Upgrade g++
sudo apt-get install gcc-4.7 g++-4.7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7

sudo update-alternatives --config gcc
# and choose gcc-4.7 as default


Modify the JuceLibraryCode/AppConfig.h
--------------------------------------

#define JUCE_USE_XSHM 0
#define JUCE_USE_XINERAMA 0

Sources:
http://www.juce.com/forum/topic/juce-raspberry-pi-opengl
https://github.com/rec/echomesh/blob/master/documentation/Building%20Juce%20applications%20on%20the%20Raspberry%20Pi.md


Build
-----
::
    make CONFIG=Release


#19

Thanks, I guess the architecture error I was getting was an error from gcc < 4.7.

Working great now.


#20

Following the above steps on Raspberry PI 2 , when I do:

make CONFIG=Release

I get a scary:

Compiling Main.cpp

*** glibc detected *** g++: double free or corruption (top): 0x00e44418 ***
Aborted
Makefile:129: recipe for target 'build/intermediate/Release/Main_90ebc5c2.o' failed
make: *** [build/intermediate/Release/Main_90ebc5c2.o] Error 134

I tried wiping the PI and starting again and reinstalling Raspbian but do joy

Any ideas what I'm doing wrong?