TUTORIAL: How to build LuaPlayer

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

sweetlilmre
Posts: 27
Joined: Sat Oct 01, 2005 7:24 pm

TUTORIAL: How to build LuaPlayer

Post by sweetlilmre »

A short guide to compiling LuaPlayer
by sweetlilmre 04 Oct 2005

Hi,

I had a hard time getting this to work so I thought a guide would be appropriate!
Lines that start with # below are comments, other lines are shell commands that should
be entered exactly as shown. Some commands will take a long time to complete, be patient.


PREREQUISITES:

You must have cygwin setup and running, I would suggest this guide: http://wiki.ps2dev.org/psp:programming_faq
NOTE: when installing cygwin, make sure you install 'opengl' under the graphics category if you wish to compile
the Windows player.


FLACK JACKET:

I like to 'make clean' before making the libs etc. Sometimes you can get halfway through a build, encounter an
error and the build will then continue to fail until you do this. If you are not as paranoid as me, forget the 'make clean'.

If you encounter errors, try a 'make clean' before continuing.


INSTRUCTIONS:

# open a cygwin shell, you should be in your home directory

mkdir source
cd source

# lets get all of the latest source for starters:

svn checkout svn://svn.ps2dev.org/psp/trunk/psptoolchain
svn checkout svn://svn.ps2dev.org/psp/trunk/lua
svn checkout svn://svn.ps2dev.org/psp/trunk/libpng
svn checkout svn://svn.ps2dev.org/psp/trunk/mikmodlib
svn checkout svn://svn.ps2dev.org/psp/trunk/zlib
svn checkout svn://svn.ps2dev.org/pspware/trunk/LuaPlayer

# sort out the toolchain and the LATEST PSPSDK

cd psptoolchain

# here is the big decision, do you need to update the PSPSDK? Then do this:
./toolchain.sh -p

# if you need to install it from scratch then do this:
# WARNING, this will take a LOOOOOOOOOOOOOOOONG time!
./toolchain.sh

cd ..


# build zlib for libpng

cd zlib
make
make install
cd ..


# build libpng

cd libpng
make
make install
cd ..


#build mikmodlib

cd mikmodlib
make install
cd ..


# build lua, NOTE: you must specifically use Makefile.psp here, Makefile is the normal Linux makefile
# which will be used later

cd lua
make -f Makefile.psp
make -f Makefile.psp install
cd ..

# Finally build the player

cd LuaPlayer
make
make install
cd ..

###########################################################################################
# To compile the windows version: #
###########################################################################################


# Once you have done all of the above:

wget http://mikmod.raphnet.net/files/mikmod-3.0.3.tar.gz
tar xvf mikmod-3.0.3.tar.gz
cd mikmod-3.0.3


# Copy the supplied Makefile (see next post) into the mikmod-3.0.3 directory
# Using the supplied Makefile:

make
make install
cd ..


# Build the Linux version of lua
# [edit]: You MUST 'make clean' here to remove the files from the PSP build

cd lua
make clean
make
make install
cd ..


# Build the Windows LuaPlayer

cd LuaPlayer
make -f Makefile.windows


# if you get errors at this point, it is probably due to missing exports in the emulator.c file.
# this means that the emulator is not yet up to date. You have 2 choices:
# 1. implement the functions yourself
# 2. wait for Shine to do so :)
#
# I am impatient ;)
Last edited by sweetlilmre on Thu Oct 06, 2005 12:29 am, edited 2 times in total.
sweetlilmre
Posts: 27
Joined: Sat Oct 01, 2005 7:24 pm

Post by sweetlilmre »

Copy below to a file called "Makefile" and put this in the mikmod-3.0.3 directory.
[edit]: okay this won't work exactly as the post does not preserve tabs...
[edit]: pm me if you want the file
-------------------------------------------------------------------------------------------

INSTALLDIR=/usr/local

OBJS = example.o

LIBS = $(INSTALLDIR)/lib/libmikmod.a $(INSTALLDIR)/lib/libmmio.a -lpspaudiolib -lpspaudio
TARGET = mikmodtest

all: libs

libs: mmio playercode
$(MAKE) -C mmio
$(MAKE) -C playercode


install: libs
@echo "Installing mikmodlib into $(INSTALLDIR)"
@mkdir -p $(INSTALLDIR)/include $(INSTALLDIR)/lib
@cp include/* $(INSTALLDIR)/include
@cp lib/* $(INSTALLDIR)/lib
@echo "Done"



clean:
$(MAKE) -C mmio clean
$(MAKE) -C playercode clean
rm -f *.o libmikmod.a mikmodtest.elf
Koba
Posts: 59
Joined: Thu Sep 29, 2005 10:57 am

Post by Koba »

ok, i did everything up to the zlib compile, i typed make, and i got this error:

Code: Select all

make: psp-config: Command not found
Makefile:9: /lib/build.mak: No such file or directory
make: *** No rule to make target '/lib/build.mak'. Stop.
any idea why this is happening? i did EVERYTHING you had there up to the zlib stuff... please help.

EDIT: hmmm nvm, seems i fixed it... i had to export everything first... you should add that to your tut...
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Would be a good idea to add this tutorial to a subpagee of http://wiki.ps2dev.org/psp:lua_player and while doing this, feel free to move the last change by joshdb to a subpage, too, perhaps called "code snippets".
sweetlilmre
Posts: 27
Joined: Sat Oct 01, 2005 7:24 pm

Post by sweetlilmre »

Koba: what did you have to export? The .rc setting for paths?
-(e)
sweetlilmre
Posts: 27
Joined: Sat Oct 01, 2005 7:24 pm

Post by sweetlilmre »

Shine:

Cool I'll look into it. Where could we host the Makefile for mikmod (the linux / cygwin makefile)? Could you put it into SVN along with the mikmod3.0.3 source?

-(e)
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

i might host it if you want me to :) (can even put up a second mirror on my isp's webspace)
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
sweetlilmre
Posts: 27
Joined: Sat Oct 01, 2005 7:24 pm

Post by sweetlilmre »

Okay, I've put it up on the wiki but in an odd kind of way!
Shine, perhaps you could fix the wiki linking.
Seems that I don't know what I'm doing here :)

-(e)
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

# if you get errors at this point, it is probably due to missing exports in the emulator.c file.
# this means that the emulator is not yet up to date. You have 2 choices:
# 1. implement the functions yourself
# 2. wait for Shine to do so :)
can't laugh at that point :(
i get TONS of errors
for example:

Code: Select all

src/emulator/emulator.c:1:23: pspkernel.h: No such file or directory
but this file is located at:

Code: Select all

pspkernel.h                          C:\cygwin\usr\local\pspdev\psp\sdk\include
this is only one of many(thousands?)
just to show up the last few:

Code: Select all

rc/emulator/windows/windows.c:48: error: initializer element is not constant
rc/emulator/windows/windows.c:48: error: (near initialization for `specialKeyM
pings[3].psp')
rc/emulator/windows/windows.c:48: error: initializer element is not constant
rc/emulator/windows/windows.c:48: error: (near initialization for `specialKeyM
pings[3]')
rc/emulator/windows/windows.c:49: error: initializer element is not constant
rc/emulator/windows/windows.c:49: error: (near initialization for `specialKeyM
pings[4]')
rc/emulator/windows/windows.c: In function `display':
rc/emulator/windows/windows.c:61: error: `u16' undeclared (first use in this f
ction)
rc/emulator/windows/windows.c:61: error: (Each undeclared identifier is report
only once
rc/emulator/windows/windows.c:61: error: for each function it appears in.)
rc/emulator/windows/windows.c: In function `main':
rc/emulator/windows/windows.c:141: warning: assignment from incompatible point
type
ake: *** [luaplayer.exe] Error 1
EDIT
i ran ./toolchain.sh -n
and ./toolchain.sh -p
so newlibs and the sdk is fresh set up;
still the same errors!

greets
Lumo
PS: hope to get that fixed
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

Errors!

=D

Code: Select all

Robin@mizukage ~/source/LuaPlayer
$ make -f Makefile.windows
gcc -o luaplayer.exe \
        src/graphics.c src/sound.c src/luaplayer.c src/luacontrols.c src/luagrap
hics.c src/luasound.c src/luasystem.c src/utility.c \
        src/emulator/emulator.c src/emulator/framebuffer.c src/emulator/windows/
windows.c src/emulator/md5.c \
        -I/usr/local/pspdev/psp/sdk/sdk/include -I/usr/local/pspdev/psp/sdk/incl
ude -Isrc -L/usr/local/lib -lglut32 -lglu32 -llua -llualib -lopengl32 -lpng -lke
rnel32
src/emulator/emulator.c:9:19: md5.inc: No such file or directory
src/emulator/emulator.c: In function `sceKernelUtilsMd5Digest':
src/emulator/emulator.c:597: error: `MD5_CTX' undeclared (first use in this func
tion)
src/emulator/emulator.c:597: error: (Each undeclared identifier is reported only
 once
src/emulator/emulator.c:597: error: for each function it appears in.)
src/emulator/emulator.c:597: error: parse error before "ctx"
src/emulator/emulator.c:598: error: `ctx' undeclared (first use in this function
)
make: *** [luaplayer.exe] Error 1
Proud Dvorak User
US 1.5 PSP (Original)
sweetlilmre
Posts: 27
Joined: Sat Oct 01, 2005 7:24 pm

Post by sweetlilmre »

Zenurb:

These are the missing functions in the emulator. I have patched the build to include these (also added serial IO, not tested and added pixel perfect collision detection: Image:hitTest ).

I am new to linux so need some assistance in generating diff / patch sets so that I can send the changes to Shine (or you).

If you can help me with this then I can sort out your errors.
As a quick fix, change the emulator.c file to include "md5.h" not "md5.inc" and that error should disappear.

btw. Thanks for the excellent edit you did on the tut, made it look MUCH better :)

-(e)
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

sweetlilmre wrote: Cool I'll look into it. Where could we host the Makefile for mikmod (the linux / cygwin makefile)? Could you put it into SVN along with the mikmod3.0.3 source?
mikmodlib is already in the SVN. Currently only the header files are used for the windows version, at least for my version. Did you manage to compile a working sound support? I don't know, if this should be done with enhancing the emulator.c or with native mikmod support.
sweetlilmre wrote: These are the missing functions in the emulator. I have patched the build to include these (also added serial IO, not tested and added pixel perfect collision detection: Image:hitTest ).

I am new to linux so need some assistance in generating diff / patch sets so that I can send the changes to Shine (or you).

If you can help me with this then I can sort out your errors.
As a quick fix, change the emulator.c file to include "md5.h" not "md5.inc" and that error should disappear.
The md5 files are already in the SVN and included in the makefile, as md5.h and md5.c, update from SVN.

The image:hitTest sounds interesting, I can include it in the SVN, send it by eMail to fb@frank-buss.de . If you want to do more for Lua Player, perhaps ask Oobles for SVN write access.
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

I'm still getting errors, but at least I'm now getting the right errors =)
Proud Dvorak User
US 1.5 PSP (Original)
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

hey, ppl, i fixed all my troubles now, big THX to sweetlilmre to help getting cygwin running!
i added a LuaPlayer for Windows modded makefile and changed source for easy compiling to mypage
so you can still build luaplayer for psp AND the windows version

greets
Lumo
ps: shall i add it to the wiki?
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

I would if I were you; Also note that people with ATI need to disable Anti-aliasing. ._.
Proud Dvorak User
US 1.5 PSP (Original)
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Wierd, LuMo.

I tried to link your web button and I got a webpage from some German guy. Something went wrong.
Geo Massar
Retired Engineer
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

I got into your web now. Strange.

Anyway, I ran my LED Timer on alpha2. Found that Timer class is not available yet. So, which version of LP for PSP does alpha2 apply to?

Thanks
Geo Massar
Retired Engineer
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

humm... i am not sure, its quite old (v0.8?)
i built one with the newest svn data (no bugfixes though!)
only the new functions are added.
added it to my page, ina winrar SFX (selfextracting) archive
required dll's are included

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

No luck. :(

I guess I'll have to wait for Shine working on his new DLL version.
I sure hope he has time to finish before the convention.
Geo Massar
Retired Engineer
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

cause more ppl had the problem by building luaplayer i decided to put a little script together like the toolchain to build luaplyaer (lpchain :) )
i linked it up in the wiki

hope you can enjoy it
greets
lumo
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

How do you select your .lua files in windows? I used a compile method on the lua.org site and came up with lua_static. now what do i do? do i have to retype ALL of my code into there? or can i point it to the index.lua? ive tried to load the index through there but it comes up (cannot define global)! how do i fix this. I dont want to retype everything. Is there a way to write your lua's in a text editor then import that .lua file? please help me. This is my first time (as you can probably tell) writing on windows i normally write on psp but i thought i would try my hand at windows. HELP!
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

open CMD
then type:
luaplayer.exe index.lua
thats it

lumo
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

About sound on desktop platform:

I stupidly removed the makefile for all platforms but PSP when putting mikmodlib together. Feel free to search the forum for the original mikmod release, and find the windows makefile in that dist, and sound support should be trivial to add to the Windows and other desktop versions of LuaPlayer. (Perhaps you can use the makefile from the official mikmod release (it's the version before the libmikmod era, 3.1.6 I believe))
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

Im sorry i just dont get it. am i supposed to get a black word prompt screen? i put in luaplayer.exe then index.lua but it says i need a "=" near index how do i solve this. do I need index.lua to be in a specific folder? i currently have it next to the static_lua file.exe i tried typing them on the same sentence and diffent lines but still nothing. Please help!!!!
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

luaplayer.exe and the script.lua need to be in the same folder;
error messages you receive, are debugging messages;
search your script for index (or use the specific line number) and look for something that requires a =

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

Can ANYONE send me(umpa_lumpa_eadu@yahoo.com) the .dll's?When i compile it it compiles OK but i cannot find the .dll file that is supposed to result from this. : ( And exactly which dll's am i supposed to have in my luaplayer.exe folder? names please. and again im incredibly sorry for all these questions.
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

grab em on my page
>LuaPlayer for Windows (alpha2)<
this is luaplayer windows with the required dll's

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

I sorta got it to work but it only opens in a flash then exits. i tried "open with" option on the lua code but it opened 2 boxes then exited. I have everything in the same folder. It just opens then quits. i only see it for a second.
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

you need to open a cmd go to the folder with luaplayer.exe and the script.lua file then type

Code: Select all

luaplayer.exe script.lua
hit enter, then it should work

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

Image ok this is my problem. i cannot get my code loaded i already asked Lumo and stuff but still. it gives me an error saying that the file doesnt exist. Ive included a picture, which shows the file tree containing my file, the error(window under the file tree) and the actual file and luaplayer in the background. PLEASE anybody that experienced or knows anything about this problem HELP ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ohh by the way the luaplayer in the command window(the one with the error) doesnt have .exe after it. please dont tell me to put .exe becuase i already did
Post Reply