Raspberry Pi

Remove the annoying SSH message when Raspbian is starting

Easy! Run ‘sudo apt-get purge pprompt’

Raspberry Pi

SDL2 on Raspberry 1.0 running Minibian (FAILED)

UPDATE 2: I did the same thing on Raspbian and the compilation worked. See this.

UPDATE 1: This didn’t work, sorry guys. I couldn’t figure it out. Tried everything, running out of time…giving up…I’m going to try to make the game another way.

I have the very first Raspberry Pi, which I believe is a 1.0. I’m trying to make a game with it and I decided to use SDL. The goal is to run SDL without X, ie from console.

The first thing I needed was a lightweight distro for the RPi. I’m using Minibian because I’ve used it before and it works. Instructions for this are pretty simple:

  1. Download Minibian (https://minibianpi.wordpress.com/download/)
  2. Use Rufus to flash it to an SD Card
  3. Run the RPi and resize the partitions (https://minibianpi.wordpress.com/how-to/resize-sd/). Read the instructions carefully especially the part about aligning the partitions.
  4. Install nano
  5. If you need Wifi, install firmware-realtek (assuming you have a Realtek based dongle) and wpasupplicant. For more info visit https://minibianpi.wordpress.com/how-to/wifi/

Next step is to install SDL:

DON’T INSTALL using the package manager, it doesn’t work. You need to compile from scratch.

  1. Install these packages required for compiling SDL (not sure if the mesa libraries are required):
    apt-get install build-essential libfreeimage-dev libopenal-dev libpango1.0-dev libsndfile1-dev libudev-dev libasound2-dev libjpeg-dev libtiff5-dev libwebp-dev automake
    apt-get install libraspberrypi-dev raspberrypi-kernel-headers
    apt-get install libegl1-mesa libegl1-mesa-dev
  2. Get SDL2 (https://www.libsdl.org/release/SDL2-2.0.5.tar.gz)
    mkdir install && cd install
    wget https://www.libsdl.org/release/SDL2-2.0.5.tar.gz
    tar zxvf SDL2-2.0.5.tar.gz
    cd SDL2-2.0.5
  3. Configure and build
    ./configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-x11
    make install
  4. FAIL!





Eclipse (Neon.2) and SDL2

After much trial and error, here are the instructions to using Eclipse and SDL2:

  1. Download and install Eclipse Neon.2 for C/C++
  2. Download and install MingW
    1. Install to C:\Mingw\
    2. In the bin folder, copy gcc.exe and rename it to mingw32-gcc.exe
  3. Download SDL2 MingW version and unzip to C:\SDL2
  4. Add C:\mingw\mingw32\bin to your PATH
  5. Copy SDL2.dll to C:\Windows\SysWOW64 if running 64-bit or C:\Windows\System32 if running 32-bit
  6. Run Eclipse
  7. Create a new C project and select MingW toolchain
  8. Add a new C source file and add this code
    #include <SDL.h>
    int main (int argc, char** argv) {
     // Create window
     SDL_Window* window = NULL;
     window = SDL_CreateWindow ( "Hello World!", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN );
     // Setup renderer
     SDL_Renderer* renderer = NULL;
     renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_ACCELERATED);
     // Set background color to red
     SDL_SetRenderDrawColor( renderer, 255, 0, 0, 255 );
     // Clear window
     SDL_RenderClear( renderer );
     // Create a square at ( 50, 50 ) with 50 width/height
     SDL_Rect r;
     r.x = 50;
     r.y = 50;
     r.w = 50;
     r.h = 50;
     // Fill square with blue color
     SDL_SetRenderDrawColor( renderer, 0, 0, 255, 255 );
     SDL_RenderFillRect( renderer, &r );
     // Draw everything to screen
     // Wait for 5 seconds
     SDL_Delay( 5000 );
     // Close window and exit
     return EXIT_SUCCESS;
  9. Add “C:\SDL2-2.0.5\i686-w64-mingw32\include\sdl2” to the Project “Include”
  10. Add “C:\SDL2-2.0.5\i686-w64-mingw32\lib” to the Project “Library Paths”
  11. Add “mingw32, sdl2main, sdl2” (in that order) to the Project “Libraries”
  12. Compile and run! 🙂