OSK Libraries

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

Moderators: cheriff, TyRaNiD

Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

OSK Libraries

Post by Producted »

Hello,

I'm trying to get Danzeff's OSK to work. However, compiling the script does not seem to work (make command). Most of the errors were saying something like "png_bytep_null undeclared" (x undeclared, implicit declaration of x etc etc). I think that the problem is; I don't have the correct libraries (yet).

Does anyone wants to RAR all the libraries which are needed for Danzeff's OSK? I know that they are in the SVN but RAR'ing them makes my life a lot easier.

Thanks already.

:)

EDIT: If anyone could also supply me with a working makefile, I would be even happier!
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Basilisk II for the PSP is a working example of using Danzeff's OSK in a program. You'll find all the files as well as how to use them in the B2 source.

http://groups.google.com/group/chilly-w ... -psp?hl=en
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

Thanks J.F. I'll walk my way through the source code of Basilisk II. I'll give a yell if I encounter any other problems.
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

Hm, that project (Basilisk) is just huge. I don't even know what I should copy and what not (if the libraries are even there).

Anyone mind telling me?
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

I used the PSPDevLibInstaller and now everything is fucked. :p
A lot of undefined references. Argh.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Danzeff is setup in main_psp.cpp at line 498. The rest is in video_psp.cpp at line 1505 and 1535.
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

It's not the OSK code which isn't working, it are the libraries;
C:\pspdev\projects\GPOS>make
psp-gcc -I. -IC:/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -LC:/pspdev/psp/sdk/l
ib danzeff.o main.o -lpspgu -ld -o hello.elf
/cygdrive/c/pspdev/bin/../lib/gcc/psp/4.0.2/../../../../psp/bin/ld: cannot find
-ld
collect2: ld returned 1 exit status
make: *** [hello.elf] Error 1
The compiler can't find them (don't tell me that I'm missing the png and other libs, I'm aware of that, just removed them for testing purposes).
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

Anyone?!
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

You have -ld in the makefile somewhere - which tells it to link the libd library... which it can't find.
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

Still not able to get it to work. :(
A lot of undefined references (to sceKernelblabla etc). What am I doing wrong?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Link in the libraries that have the functions it says are undefined.
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

LIBS = -lstdc++ -lpsprtc -lpspwlan -lpspgum -lpspgu -lpspaudio -lm -lpsppower
C:\pspdev\projects\GPOS>make
psp-gcc -I. -IC:/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -LC:/pspdev/psp/sdk/l
ib danzeff.o main.o -lstdc++ -lpsprtc -lpspwlan -lpspgum -lpspgu -lpspaudio -l
m -lpsppower -o hello.elf
/cygdrive/c/pspdev/bin/../lib/gcc/psp/4.0.2/../../../../psp/lib/crt0.o: In funct
ion `_main':
/home/loser/newtoolchain/pspsdk/src/startup/crt0.c:68: undefined reference to `s
trlen'
/home/loser/newtoolchain/pspsdk/src/startup/crt0.c:83: undefined reference to `a
texit'
/home/loser/newtoolchain/pspsdk/src/startup/crt0.c:89: undefined reference to `e
xit'
/cygdrive/c/pspdev/bin/../lib/gcc/psp/4.0.2/../../../../psp/lib/crt0.o: In funct
ion `_start':
/home/loser/newtoolchain/pspsdk/src/startup/crt0.c:149: undefined reference to `
sceKernelCreateThread'
/home/loser/newtoolchain/pspsdk/src/startup/crt0.c:150: undefined reference to `
sceKernelStartThread'
main.o: In function `exit_callback':
main.c:(.text+0x8): undefined reference to `sceKernelExitGame'
main.o: In function `CallbackThread':
main.c:(.text+0x38): undefined reference to `sceKernelCreateCallback'
main.c:(.text+0x40): undefined reference to `sceKernelRegisterExitCallback'
main.c:(.text+0x48): undefined reference to `sceKernelSleepThreadCB'
main.o: In function `SetupCallbacks':
main.c:(.text+0x88): undefined reference to `sceKernelCreateThread'
main.c:(.text+0xa4): undefined reference to `sceKernelStartThread'
main.o: In function `substr':
main.c:(.text+0xc8): undefined reference to `strncat'
main.o: In function `main':
main.c:(.text+0xe4): undefined reference to `pspDebugScreenInit'
main.c:(.text+0xf4): undefined reference to `danzeff_load'
main.c:(.text+0x134): undefined reference to `pspDebugScreenPrintf'
main.c:(.text+0x140): undefined reference to `sceKernelDelayThread'
main.c:(.text+0x150): undefined reference to `sceKernelSleepThread'
main.c:(.text+0x178): undefined reference to `danzeff_render'
collect2: ld returned 1 exit status
make: *** [hello.elf] Error 1
What am I doing wrong? :s

EDIT:
#include <pspkernel.h>
#include <pspdebug.h>
#include <string.h>
#include <stdio.h>
#include "danzeff.h"
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

From the error message, it doesn't look like a normal PSPSDK makefile... show your makefile here. Again, for reference, look at the makefile in the B2 src/PSP directory (not the original makefile).
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

TARGET = GPOS
OBJS = main.o danzeff.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = GPOS

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

LIBS = -lpspgu
LIBDIR = $(PSPDEV)/SDK/lib
:(
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Okay, the LIBDIR line was in B2 only because B2 used a library from D_A's SDK. If you are using D_A's SDK, you don't need to specify that. Also, your LIBS = line is a bit slim... what happened to all the other libs you specified in the post previously? If it's C++, you need to specify stdc++ at least. Also, moves the LIBS ad LIBDIR lines above the EXTRA_TARGETS line. I'm not sure the position makes a difference, but I'm not sure it works if it's after the include line since then neither are defined when the included file is included.
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

Thanks alot J.F, I'm close now.

New makefile:
TARGET = GPOS
OBJS = danzeff.o main.o

LIBS = -lstdc++ -lpsprtc -lpspwlan -lpspgum -lpspgu -lpspaudio -lm -lpsppower
LIBDIR = $(PSPDEV)/SDK/lib

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = GPOS

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
New console output:
C:\pspdev\projects\GPOS>make
psp-gcc -I. -IC:/pspdev/psp/sdk/include -O2 -G0 -Wall -LC:/pspdev/SDK/lib -L. -
LC:/pspdev/psp/sdk/lib danzeff.o main.o -lstdc++ -lpsprtc -lpspwlan -lpspgum -
lpspgu -lpspaudio -lm -lpsppower -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpsp
sdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lp
spuser -lpspkernel -o GPOS.elf
main.o: In function `main':
main.c:(.text+0xf4): undefined reference to `danzeff_load'
main.c:(.text+0x178): undefined reference to `danzeff_render'
collect2: ld returned 1 exit status
make: *** [GPOS.elf] Error 1
And yes, I did included the danzeff.h file at the start of main.c.

Any suggestions?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Switch main.o and danzeff.o. The link order of object files is as important as the link order of libraries. I think that should do it. There's just a little bit of an art to making these things, but you seem to be catching on quickly. :)
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

Too bad... Even after switching those two (like OBJS = main.o danzeff.o), I'm still getting the same console output as before.
Any other suggestions?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Producted wrote:Too bad... Even after switching those two (like OBJS = main.o danzeff.o), I'm still getting the same console output as before.
Any other suggestions?
Make sure you have the function names correct. Capitalization counts. :)
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

Nah, that isn't the problem.

Code: Select all

int main&#40;&#41; 
&#123; 

	pspDebugScreenInit&#40;&#41;;
	SetupCallbacks&#40;&#41;;

	danzeff_load&#40;&#41;;
	if&#40;danzeff_isinitialized&#40;&#41;&#41; 
	&#123;

		danzeff_render&#40;&#41;;
	
	&#125;

	// Other stuff here

	sceKernelSleepThread&#40;&#41;;

	return 0;
&#125;
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Make sure your danzeff.h has this in it near the top

Code: Select all

#ifdef __cplusplus
extern "C" &#123;
#endif
I know I've had to add that to other PSP includes, I just don't remember if danzeff.h had that originally.
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

Danzeff.h was already containing those lines by default. :p
Any other things I need to add / modify? (or suggestions)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

How about your latest makefile and the full output of the compiler?
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

Sorry for the late reply, but I was busy with school and such stuff.

Anyway, latest makefile:
TARGET = GPOS
OBJS = main.o danzeff.o

LIBS = -lstdc++ -lpsprtc -lpspwlan -lpspgum -lpspgu -lpspaudio -lm -lpsppower
LIBDIR = $(PSPDEV)/SDK/lib

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = GPOS

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Full output of the compiler:
C:\pspdev\projects\GPOS>make
psp-gcc -I. -IC:/pspdev/psp/sdk/include -O2 -G0 -Wall -LC:/pspdev/SDK/lib -L. -
LC:/pspdev/psp/sdk/lib main.o danzeff.o -lstdc++ -lpsprtc -lpspwlan -lpspgum -
lpspgu -lpspaudio -lm -lpsppower -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpsp
sdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lp
spuser -lpspkernel -o GPOS.elf
main.o: In function `main':
main.c:(.text+0xf4): undefined reference to `danzeff_load'
main.c:(.text+0x178): undefined reference to `danzeff_render'
collect2: ld returned 1 exit status
make: *** [GPOS.elf] Error 1
(:
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Did you just change the danzeff.c to cpp? If so you'll need to add extern "C" {} around the functions themselves or the names will be mangled.
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

^
I don't exactly get where you are pointing at. If you are talking about those extern lines, danzeff.h was already containing them by default. And I didn't changed the extension .c to .cpp.
I'll try that but I don't think it's going to work...

EDIT: Nope :(
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

What firmware are you building for anyway?
Maybe adding these lines to your makefile could help...

Code: Select all

BUILD_PRX = 1
PSP_FW_VERSION = xxx &#40;enter yours&#41;
...sorry for my english...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Producted wrote:^
I don't exactly get where you are pointing at. If you are talking about those extern lines, danzeff.h was already containing them by default. And I didn't changed the extension .c to .cpp.
I'll try that but I don't think it's going to work...

EDIT: Nope :(
You NEED danzeff to be C code. It needs to be .c and compiled by gcc, or it needs the extern "C" {} and be compiled by g++. If you don't understand C++ name mangling (which is almost certainly the problem here), then you should post more of the code so we can see where it's wrong. As it is, we're guessing based of a couple error lines and your assertions that you're doing it right.

Look at how it's used in Basilisk II - look at how the filenames are done, look at what is enclosed in extern "C" {}, look at how it's compiled.
slasher2661996
Posts: 91
Joined: Sun Feb 22, 2009 8:32 am
Location: Melbourne Australia ZOMG

Post by slasher2661996 »

Define a prototype for the functions
Producted
Posts: 56
Joined: Thu Jun 04, 2009 12:16 am

Post by Producted »

I do have all the correct extensions, danzeff.c is containing these lines:
#ifndef INCLUDED_KEYBOARDS_DANZEFF_H
#define INCLUDED_KEYBOARDS_DANZEFF_H

//danzeff is BSD licensed, if you do make a new renderer then please share it back and I can add it
//to the original distribution.

//Set which renderer target to build for
/* #define DANZEFF_SDL */
/* #define DANZEFF_SCEGU */


//the SDL implementation needs the pspctrl_emu wrapper to convert
//a SDL_Joystick into a SceCtrlData
#ifdef DANZEFF_SDL
#include "pspctrl_emu.h"
#else //not DANZEFF_SDL
#include <pspctrl.h>
#endif //DANZEFF_SDL


#ifdef __cplusplus
extern "C" {
#endif


[..]

#ifdef __cplusplus
}
#endif

#endif //INCLUDED_KEYBOARDS_DANZEFF_H
The filenames in Basilisk II\src\PSP\Danzeff are the same as the extensions of my danzeff files. My makefile is almost the same as Basillisk's makefile (except from the stuff I won't need).

I tried the thing which kralyk said, with no result (I don't see why it would work anyway, BUILD_PRX means that I'm working on a PRX which I'm not (right?))

Slasher could you explain what "defining a prototype for the functions" means?

What did I forgot?
Post Reply