SDL Tutorial lesson 2

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
pspblizz
Posts: 15
Joined: Tue Sep 13, 2005 8:35 pm

SDL Tutorial lesson 2

Post by pspblizz »

After giving up on getting cygwin + psptoolchain to work, I spent a few hours getting SDL, PSPSDK + toolchain up on my Suse box. Worked like a charm.

My next step was to follow a tutorial on SDL, easy as pie. With a few minor modifications I got it working on my PSP.

The filestructure in this RAR file suxx, you'll need to put the "Makefile" and "lesson2.cpp" somewhere else! But it's there for you to study :)

http://rapidshare.de/files/5161304/lesson2.rar

The tutorial I follow can be found here:
http://cone3d.gamedev.net/cgi-bin/index ... fxsdl/tut2

And I stole some PSP doublebuffering adjustments from here:
http://svn.ps2dev.org/filedetails.php?r ... rev=0&sc=0
  • What I should have done differently:
  • A better joystick code, my Java training should have made me understand events better!!! :)
  • A better file layout, There is code on this forum for "releative filepaths"!
  • Better SDL_main code, quick and dirt fix to make it work :)
  • What I will do in the future
  • Make a 1.2.3 guide to get libSDL into your environment for other n00bs like me
  • Convert the rest of the SDL tutorials
  • Make my own game! :)
  • What I wish for in the future(that others make)
  • A port of the SDL_net to PSP
  • 2.0 homebrew
  • PSIX Shell
  • Peace on earth and prosperity to all of man kind
rinco
Posts: 255
Joined: Fri Jan 21, 2005 2:12 pm
Location: Canberra, Australia

Post by rinco »

Make a 1.2.3 guide to get libSDL into your environment for other n00bs like me
The big hurdle for most seems to be using svn and following the build instructions for each package.
But in any case, here's a little script that can install all of SDL:

Code: Select all

#!/bin/sh

SRCDIR="`pwd`"
TMPDIR="/tmp/pspsdl"
SVN="svn"

mkdir -p $TMPDIR
cd $TMPDIR

SDL_PKGS="SDL SDL_gfx SDL_image jpeg libpng zlib SDL_mixer SDL_ttf freetype"
for pkg in $SDL_PKGS ; do
        rm -Rf $pkg
        $SVN checkout svn://svn.pspdev.org/psp/trunk/$pkg
done

cd SDL
./autogen.sh
LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspuser" \
        ./configure --host psp --prefix=`psp-config --psp-prefix`
make
make install
cd $TMPDIR

cd zlib
make
make install
cd $TMPDIR

cd libpng
make
make install
cd $TMPDIR

cd jpeg
make
make install
cd $TMPDIR

cd SDL_image
./autogen.sh
LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspuser" \
        ./configure --host psp --with-sdl-prefix=`psp-config --psp-prefix` \
        --prefix=`psp-config --psp-prefix`
make
make install
cd $TMPDIR

cd SDL_gfx
./autogen.sh
AR=psp-ar LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspuser" \
        ./configure --host psp --with-sdl-prefix=`psp-config --psp-prefix` \
        --prefix=`psp-config --psp-prefix` --disable-mmx --disable-shared
make
make install
cd $TMPDIR

cd freetype
./autogen.sh
LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspuser" \
        ./configure --host psp --prefix=`psp-config --psp-prefix`
make
make install
cd $TMPDIR

cd SDL_ttf
./autogen.sh
LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspuser" \
        ./configure --host psp --with-sdl-prefix=`psp-config --psp-prefix` \
        --with-freetype-prefix=`psp-config --psp-prefix` \
        --without-x --prefix=`psp-config --psp-prefix`
make
make install
cd $TMPDIR

cd SDL_mixer
./autogen.sh
LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspuser" \
        ./configure --host psp --with-sdl-prefix=`psp-config --psp-prefix` \
        --disable-music-mp3 --prefix=`psp-config --psp-prefix`
make
make install
cd $TMPDIR

cd $SRCDIR
#for pkg in $SDL_PKGS ; do
#        rm -Rf $pkg
#done
#
#rmdir $TMPDIR
And there's a few ports in the svn pspware repository that can be used to test the installation:
abrick - for testing SDL_mixer
vecteroids - depends upon SDL_image and SDL_mixer
SMC - requires SDL_ttf, SDL_mixer, SDL_image and SDL_gfx

Also, it is interesting to note that these source packages can be reused on your host platform; just build the packages downloaded from pspsvn by running ./configure (ie: without all the psp specifics). Running 'make clean' first would be a wise move.
daveyc
Posts: 5
Joined: Sat Sep 24, 2005 11:59 am

Post by daveyc »

I've tried using your script, and most of the packages install correctly, but it fails when trying to install freetype. I'm using the latest toolchain and I've tried it on cygwin and on linux (fedora).

Here's the contents of config.log:

Any ideas?

Code: Select all

## ----------- ##
## Core tests. ##
## ----------- ##

configure:1537: checking build system type
configure:1555: result: i686-pc-cygwin
configure:1563: checking host system type
configure:1577: result: mipsallegrexel-psp-elf
configure:1585: checking target system type
configure:1599: result: mipsallegrexel-psp-elf
configure:1625: checking for psp-gcc
configure:1641: found /usr/local/pspdev/bin/psp-gcc
configure:1651: result: psp-gcc
configure:1933: checking for C compiler version
configure&#58;1936&#58; psp-gcc --version </dev/null >&5
psp-gcc &#40;GCC&#41; 4.0.1 &#40;PSPDEV 20050827&#41;
Copyright &#40;C&#41; 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure&#58;1939&#58; $? = 0
configure&#58;1941&#58; psp-gcc -v </dev/null >&5
Using built-in specs.
Target&#58; psp
Configured with&#58; ../configure --prefix=/usr/local/pspdev --target=psp --enable-languages=c,c++ --with-newlib --enable-cxx-flags=-G0
Thread model&#58; single
gcc version 4.0.1 &#40;PSPDEV 20050827&#41;
configure&#58;1944&#58; $? = 0
configure&#58;1946&#58; psp-gcc -V </dev/null >&5
psp-gcc&#58; '-V' option must have argument
configure&#58;1949&#58; $? = 1
configure&#58;1972&#58; checking for C compiler default output file name
configure&#58;1975&#58; psp-gcc    conftest.c  >&5
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/crt0.o&#58; In function `_main'&#58;
/tmp/pspdev/pspsdk/sdk/startup/crt0.c&#58;72&#58; undefined reference to `atexit'
/tmp/pspdev/pspsdk/sdk/startup/crt0.c&#58;78&#58; undefined reference to `exit'
/tmp/pspdev/pspsdk/sdk/startup/crt0.c&#58;65&#58; undefined reference to `strlen'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/crt0.o&#58; In function `_start'&#58;
/tmp/pspdev/pspsdk/sdk/startup/crt0.c&#58;134&#58; undefined reference to `sceKernelCreateThread'
/tmp/pspdev/pspsdk/sdk/startup/crt0.c&#58;135&#58; undefined reference to `sceKernelStartThread'
collect2&#58; ld returned 1 exit status
configure&#58;1978&#58; $? = 1
configure&#58; failed program was&#58;
| /* confdefs.h.  */
| 
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| 
| int
| main &#40;&#41;
| &#123;
| 
|   ;
|   return 0;
| &#125;
configure&#58;2017&#58; error&#58; C compiler cannot create executables
See `config.log' for more details.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

What's the command line you pass to configure? Are you you using

Code: Select all

LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspuser" ./configure --host psp --prefix=`psp-config --psp-prefix`
as found in README.PSP?
daveyc
Posts: 5
Joined: Sat Sep 24, 2005 11:59 am

Post by daveyc »

Yup, that's the one
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Are you using bash (or a compatible shell) or csh? It's strange that your linker options aren't showing up in config.log. And to be on the safe side, what versions of autoconf and automake do you have installed?
warpdesign
Posts: 2
Joined: Wed May 27, 2009 9:00 am

Post by warpdesign »

configure: failed program was:
| /* confdefs.h. */
|
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
...
I just downloaded a fresh toolchain, built everything, and when trying to build SDL libs (after having downloaded it from SVN trunk), I'm having the exact same error when trying to run configure...

But we're 4 years later... and still no answer :/

When running the configure line found in README.PSP, I first have the following warning:
$ ./configure --host psp --prefix=`psp-config --psp-prefix`
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
Then this error..
checking for C compiler default output file name...
configure: error: in `/home/warpdesign/temp/SDL':
configure: error: C compiler cannot create executables
See `config.log' for more details.
And the error found quoted above can be found in config.log
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

warpdesign wrote:
configure: failed program was:
| /* confdefs.h. */
|
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
...
I just downloaded a fresh toolchain, built everything, and when trying to build SDL libs (after having downloaded it from SVN trunk), I'm having the exact same error when trying to run configure...

But we're 4 years later... and still no answer :/

When running the configure line found in README.PSP, I first have the following warning:
$ ./configure --host psp --prefix=`psp-config --psp-prefix`
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
Then this error..
checking for C compiler default output file name...
configure: error: in `/home/warpdesign/temp/SDL':
configure: error: C compiler cannot create executables
See `config.log' for more details.
And the error found quoted above can be found in config.log
What platform are you using?
The warning is normal.

The config log error is not specific enough you'll need to paste the entire log to pastebin.
warpdesign
Posts: 2
Joined: Wed May 27, 2009 9:00 am

Post by warpdesign »

I'm having the exact same error as reported by daveyc:
undefined reference to `sceKernelCreateThread'
...
I'll past the full log later if needed though.

I'm using Windows/cygwin, don't remember GCC version, I'll post the details if needed.

Thanks.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

When running the configure line found in README.PSP, I first have the following warning:

Quote:

$ ./configure --host psp --prefix=`psp-config --psp-prefix`
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
That's not the configure line found in README.PSP. It is:
$ LDFLAGS="-L$(psp-config --pspsdk-path)/lib -lc -lpspuser" ./configure --host psp --prefix=$(psp-config --psp-prefix)
as shown here:
http://psp.jim.sh/svn/filedetails.php?r ... README.PSP
Post Reply