Common errors and Solutions

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Common errors and Solutions

Post by Agoln »

OK, after reading these forums, I have compiled a list of some of the much more common errors that happen when compiling and using the SDK.

Q:HelloWorld Problems
A:This program is a problem in itself as of right now. It is outdated and you shouldn't try to compile it. Get the PSPSDK and try and compile the samples there.

Q:/bin/sh: no: command not found
A:Make sure you have gcc installed. While you're at it, make sure that autoconf and automake are there too. These are necessary tools to compile the SDK.

Q:bash: ./configure: Permission denied
A:Do a

Code: Select all

chmod +x ./configure
Q:./bootstrap: line 81: aclocal: command not found
./bootstrap: line 83: autoheader: command not found
./bootstrap: line 84: automake: command not found
./bootstrap: line 86: autoconf: command not found

A:Install automake and autoconf.

Q: In function `__entrytable':
crt0.S:(.rodata.sceResident+0xc): undefined reference to `module_info'

A:Make sure that you have PSP_MODULE_INFO("SOMETHING", 0, 1, 1); somewhere in your program.

Q:In function `_sbrk_r':
../../../../../newlib/libc/reent/sbrkr.c:60: undefined reference to `sbrk'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(makebuf.o): In function `__smakebuf':
../../../../../newlib/libc/stdio/makebuf.c:96: undefined reference to `isatty'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(writer.o): In function `_write_r':
../../../../../newlib/libc/reent/writer.c:58: undefined reference to `_write'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(closer.o): In function `_close_r':
../../../../../newlib/libc/reent/closer.c:53: undefined reference to `_close'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(fstatr.o): In function `_fstat_r':
../../../../../newlib/libc/reent/fstatr.c:62: undefined reference to `_fstat'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(lseekr.o): In function `_lseek_r':
../../../../../newlib/libc/reent/lseekr.c:58: undefined reference to `_lseek'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(readr.o): In function `_read_r':
../../../../../newlib/libc/reent/readr.c:58: undefined reference to `_read'

A:Delete any previous installation of your toolchain and make sure you grab the latest toolchain and SDK from svn.

To get it, install subversion and do a

Code: Select all

svn co svn://svn.pspdev.org/psp/trunk/pspsdk
svn co svn://svn.pspdev.org/psp/trunk/psptoolchain
Q:Why can't I use the math.h file? It is giving undefined errors.
A:Put a -lm in your linked libraries.

Q:I have installed the toolchain and SDK, but it says 'psp-gcc command not found' or 'make: psp-config: Command not found'.
A:Stated in the README:
Code:
export PATH="/usr/local/pspdev/bin:$PATH"

(You can also add the above four lines to your .bash_profile, to save you from typing it in each time you open a new console window.)
Q:In Cygwin, it says 'wget: command not found'
A:Install the wget package.

Q:In Cygwin, it says 'gmake: command not found'
A:Install the make package

Q:I get 'Undefined Reference to __errorno'
A:Until the sdk is fixed for __errno just add

Code: Select all

int __errno = 0;

to your main C file.
(This may even be fixed by updating to the new SDK)

Many, many other errors can be solved by just checking out the latest toolchain / sdk from svn.

Any others to add to the list?
Lego of my Ago!
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Updated to remove unneeded environment variables and added 'make: psp-config: Command not found'.
The Operator
Posts: 3
Joined: Wed Jan 11, 2006 4:42 am
Location: Atlanta
Contact:

Post by The Operator »

I am using psptoolchain-20051202 and i am getting the exact same error over and over when i try to install it. i have tried going out and getting the most up to date one and this is the one i find. I also tried running it with ./toolchain.sh -p to in stall just the psp sdk becuase that is where it is saying it is getting the error. here it is.

Code: Select all

In file included from inethelper.c:18:
../../src/net/pspnet_resolver.h:22:24: error: netinet/in.h: No such file or dire
ctory
In file included from inethelper.c:18:
../../src/net/pspnet_resolver.h:62: warning: 'struct in_addr' declared inside pa
rameter list
../../src/net/pspnet_resolver.h:62: warning: its scope is only this definition o
r declaration, which is probably not what you want
../../src/net/pspnet_resolver.h:76: warning: 'struct in_addr' declared inside pa
rameter list
make[3]: *** [inethelper.o] Error 1
make[3]: Leaving directory `/tmp/pspdev/pspsdk/src/sdk'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/tmp/pspdev/pspsdk/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/pspdev/pspsdk'
make: *** [all] Error 2
ERROR BUILDING PSPSDK
[/code]
Insert witty and meaningful sig here......
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Well... you need to latest toolchain from subversion, or at least the latest newlib patch. Stuff which was deemed to be in newlib's domain (i.e. standard socket headers) are in newlib. Unfortunately pspsdk now depends on those files being there, which is what is causing the problems :(
The Operator
Posts: 3
Joined: Wed Jan 11, 2006 4:42 am
Location: Atlanta
Contact:

Post by The Operator »

Okay can i just run ./toolchain -n to install the latest newlib? or do i need to go get it and redo the whole installation.
Insert witty and meaningful sig here......
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

You should be able to just do toolchain -n yes
Yue
Posts: 2
Joined: Mon Aug 28, 2006 9:33 am
Contact:

Simple error (I think)

Post by Yue »

Hello everyone!

I just installed everything in order to develop for PSP. However, I tried to compile the following code I created just for testing the pad:

Code: Select all

#include <pspdisplay.h>
#include <pspctrl.h>
#define printf pspDebugScreenPrintf

PSP_MODULE_INFO&#40;"For Emi",0,1,1&#41;;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
    sceKernelExitGame&#40;&#41;;
    return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
    int cbid;
    
    cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, 0&#41;;
    sceKernelRegisterExitCallback&#40;cbid&#41;;
    
    sceKernelSleepThreadCB&#40;&#41;;
    
    return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
    int thid = 0;
    
    thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
    if&#40;thid >= 0&#41; &#123;
	sceKernelStartThread&#40;thid, 0, 0&#41;;
    &#125;

    return thid;
&#125;

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

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

    SceCtrlData pad;

    
    printf&#40;"Some message"&#41;;
    printf&#40;"Some message"&#41;;

    while &#40;1&#41; &#123;
	sceCtrlReadBufferPositive&#40;&pad,1&#41;;

	if &#40;pad.Buttons && PSP_CTRL_CIRCLE&#41; &#123;
	    printf&#40;"Circle"&#41;;
	&#125;
	else &#123;
	    if &#40;pad.Buttons && PSP_CTRL_CROSS&#41; &#123;
		printf&#40;"Cross"&#41;;
	    &#125;
	    else &#123;
		if &#40;pad.Buttons && PSP_CTRL_SQUARE&#41; &#123;
		    printf&#40;"Square"&#41;;
		&#125;
		else &#123;
		    if &#40;pad.Buttons && PSP_CTRL_TRIANGLE&#41; &#123;
			printf&#40;"Triangle"&#41;;
		    &#125;
		&#125;
	    &#125;
	&#125;
    &#125;

    sceKernelSleepThread&#40;&#41;;

    return 0;
&#125;
I named the file "foremi.c". The Makefile looks like this:

Code: Select all

TARGET = foremi
OBJS = foremi.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = For Emi

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
But when I run make, I get the following:

Code: Select all

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall   -c -o foremi.o foremi.c
foremi.c&#58;5&#58; error&#58; syntax error before string constant
foremi.c&#58;5&#58; &#35686;&#21578;&#58; type defaults to ‘int’ in declaration of ‘PSP_MODULE_INFO’
foremi.c&#58;5&#58; &#35686;&#21578;&#58; &#12487;&#12540;&#12479;&#23450;&#32681;&#12364;&#22411;&#12420;&#35352;&#25014;&#12463;&#12521;&#12473;&#12434;&#25345;&#12387;&#12390;&#12356;&#12414;&#12379;&#12435;
foremi.c&#58; In function ‘exit_callback’&#58;
foremi.c&#58;9&#58; &#35686;&#21578;&#58; implicit declaration of function ‘sceKernelExitGame’
foremi.c&#58; &#12488;&#12483;&#12503;&#12524;&#12505;&#12523;&#58;
foremi.c&#58;14&#58; error&#58; syntax error before ‘args’
foremi.c&#58; In function ‘CallbackThread’&#58;
foremi.c&#58;17&#58; &#35686;&#21578;&#58; implicit declaration of function ‘sceKernelCreateCallback’
foremi.c&#58;18&#58; &#35686;&#21578;&#58; implicit declaration of function ‘sceKernelRegisterExitCallback’
foremi.c&#58;20&#58; &#35686;&#21578;&#58; implicit declaration of function ‘sceKernelSleepThreadCB’
foremi.c&#58; In function ‘SetupCallbacks’&#58;
foremi.c&#58;29&#58; &#35686;&#21578;&#58; implicit declaration of function ‘sceKernelCreateThread’
foremi.c&#58;31&#58; &#35686;&#21578;&#58; implicit declaration of function ‘sceKernelStartThread’
foremi.c&#58; In function ‘main’&#58;
foremi.c&#58;39&#58; &#35686;&#21578;&#58; implicit declaration of function ‘pspDebugScreenInit’
foremi.c&#58;45&#58; &#35686;&#21578;&#58; implicit declaration of function ‘pspDebugScreenPrintf’
foremi.c&#58;71&#58; &#35686;&#21578;&#58; implicit declaration of function ‘sceKernelSleepThread’
make&#58; *** &#91;foremi.o&#93; &#12456;&#12521;&#12540; 1
If you can't see some characters from this output, don't worry. I use SUSE Linux 10.1 in Japanese, that's why the characters are in that language.

I'm pretty sure that the error is very very basic, but since I'm a beginner in PSP development and it's been a while since the last time I programmed in C, I better ask to the experts.

I'd be grateful for any tips you can tell me.

Thanks in advance.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

This is the wrong thread for this really.

Regardless, add these two lines to the start of your code:

Code: Select all

#include <pspdebug.h>
#include <pspkernel.h>
You'd also be better using else if instead of all those else, like so:

Code: Select all

if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;
     printf&#40;"Circle"&#41;;
else if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;
     printf&#40;"Cross"&#41;;
else if &#40;pad.Buttons & PSP_CTRL_SQUARE&#41;
     printf&#40;"Square"&#41;;
else if &#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41;
     printf&#40;"Triangle"&#41;;
Yue
Posts: 2
Joined: Mon Aug 28, 2006 9:33 am
Contact:

Post by Yue »

Thanks a lot for the reply and sorry for posting in the wrong place. I will try that!
Post Reply