| View previous topic :: View next topic |
| Author |
Message |
mrdelayer
Joined: 10 Jul 2005 Posts: 16
|
Posted: Sun Jul 10, 2005 5:26 pm Post subject: BLARGH! Won't compile! |
|
|
so i wrote a little psp pi calculation program based on one of the ones found at projectpi (http://projectpi.sourceforge.net) and some of pspkrazy's logging code... when i go to make it, it does this:
| Code: | Matt@steamloller /usr/local/pspdev/psp/sdk/samples/pi
$ psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/pspdev/psp/sdk/lib main.o -lpspdebug -lpsplibc -lpspkernel -lm -o pi.elf
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/crt0.o: In function `__e
ntrytable':
crt0.S:(.rodata.sceResident+0xc): undefined reference to `module_info'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libm.a(w_sqrt.o): In function `sqrt':
../../../../../newlib/libm/math/w_sqrt.c:83: undefined reference to `__errno'
../../../../../newlib/libm/math/w_sqrt.c:86: undefined reference to `__errno'
collect2: ld returned 1 exit status |
here is the code to my program:
| Code: | #include <pspkernel.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#define O_RDONLY 0x0001
#define O_WRONLY 0x0002
#define O_RDWR 0x0003
#define O_NBLOCK 0x0010
#define O_APPEND 0x0100
#define O_CREAT 0x0200
#define O_TRUNC 0x0400
#define O_NOWAIT 0x8000
int file = 0;
int LogOpen(char *path) {
file = sceIoOpen(path, PSP_O_CREAT|PSP_O_RDWR|PSP_O_TRUNC, 0777);
return file;
}
int LogClose() {
if(file)
sceIoClose(file);
return 0;
}
int LogPrintf(char *fmt, ...) {
va_list opt;
char buff[2048];
int bufsz;
va_start(opt, fmt);
bufsz = vsnprintf( buff, (size_t) sizeof(buff), fmt, opt);
sceIoWrite(file, buff, bufsz);
return 0;
}
double find(double x,double a) {
double y;
y=sqrt((a*a)-(x*x));
return y;
};
int main() {
file = LogOpen("ms0:/pi.txt");
double ind,delta,rad,dec,sum=0.0,x,y,xnow,ynow,length;
rad = 300;
printf("Radius = 300\n");
LogPrintf("Radius = 300\n");
dec = 0.1;
printf("Decrease in x = 0.1\n");
LogPrintf("Decrease in x = 0.1\n");
x=rad;
y=0.0;
delta=rad/100.0;
ind=1.0;
for(xnow=rad;xnow>=0.0;xnow=xnow-dec) {
ynow=find(xnow,rad);
length=sqrt(((x-xnow)*(x-xnow))+((ynow-y)*(ynow-y)));
sum=sum+length;
x=xnow;
y=ynow;
if(xnow<=rad-(ind*delta)) {
printf("\n%.0lf of 100 completed.",ind);
LogPrintf("\n%.0lf of 100 completed.",ind);
ind=ind+1.0;
};
};
LogPrintf("Pi=%.10lf",2.0*sum/rad);
LogClose();
printf("\nPi=%.10lf",2.0*sum/rad);
sceKernelExitGame();
return(0);
};
|
it's probably something really minor that i overlooked because it's 2:30 in the morning :| any ideas, though? |
|
| Back to top |
|
 |
deagle
Joined: 29 Jun 2005 Posts: 8
|
Posted: Sun Jul 10, 2005 7:09 pm Post subject: |
|
|
| Quote: | | crt0.S:(.rodata.sceResident+0xc): undefined reference to `module_info' |
I think you've forgotten to add the PSP_MODULE_INFO line in the code
example :
| Quote: | | PSP_MODULE_INFO("Name of your program", 0, 1, 1); |
right after the headers includes |
|
| Back to top |
|
 |
mrdelayer
Joined: 10 Jul 2005 Posts: 16
|
Posted: Sun Jul 10, 2005 7:16 pm Post subject: |
|
|
| well, that fixed the module_info thing... no luck with the __errno errors though :| |
|
| Back to top |
|
 |
squiggle
Joined: 26 Jun 2005 Posts: 9
|
Posted: Sun Jul 10, 2005 8:33 pm Post subject: |
|
|
worked for me when I tried to build it with the latest pspsdk out of svn. So it looks like the bugs been fixed.
Radius = 300
Decrease in x = 0.1
1 of 100 completed.
2 of 100 completed.
3 of 100 completed.
4 of 100 completed.
5 of 100 completed.
6 of 100 completed.
7 of 100 completed.
8 of 100 completed.
9 of 100 completed.
10 of 100 completed.
11 of 100 completed.
12 of 100 completed.
13 of 100 completed.
14 of 100 completed.
15 of 100 completed.
16 of 100 completed.
17 of 100 completed.
18 of 100 completed.
19 of 100 completed.
20 of 100 completed.
21 of 100 completed.
22 of 100 completed.
23 of 100 completed.
24 of 100 completed.
25 of 100 completed.
26 of 100 completed.
27 of 100 completed.
28 of 100 completed.
29 of 100 completed.
30 of 100 completed.
31 of 100 completed.
32 of 100 completed.
33 of 100 completed.
34 of 100 completed.
35 of 100 completed.
36 of 100 completed.
37 of 100 completed.
38 of 100 completed.
39 of 100 completed.
40 of 100 completed.
41 of 100 completed.
42 of 100 completed.
43 of 100 completed.
44 of 100 completed.
45 of 100 completed.
46 of 100 completed.
47 of 100 completed.
48 of 100 completed.
49 of 100 completed.
50 of 100 completed.
51 of 100 completed.
52 of 100 completed.
53 of 100 completed.
54 of 100 completed.
55 of 100 completed.
56 of 100 completed.
57 of 100 completed.
58 of 100 completed.
59 of 100 completed.
60 of 100 completed.
61 of 100 completed.
62 of 100 completed.
63 of 100 completed.
64 of 100 completed.
65 of 100 completed.
66 of 100 completed.
67 of 100 completed.
68 of 100 completed.
69 of 100 completed.
70 of 100 completed.
71 of 100 completed.
72 of 100 completed.
73 of 100 completed.
74 of 100 completed.
75 of 100 completed.
76 of 100 completed.
77 of 100 completed.
78 of 100 completed.
79 of 100 completed.
80 of 100 completed.
81 of 100 completed.
82 of 100 completed.
83 of 100 completed.
84 of 100 completed.
85 of 100 completed.
86 of 100 completed.
87 of 100 completed.
88 of 100 completed.
89 of 100 completed.
90 of 100 completed.
91 of 100 completed.
92 of 100 completed.
93 of 100 completed.
94 of 100 completed.
95 of 100 completed.
96 of 100 completed.
97 of 100 completed.
98 of 100 completed.
99 of 100 completed.Pi=3.1415908644 |
|
| Back to top |
|
 |
mrdelayer
Joined: 10 Jul 2005 Posts: 16
|
Posted: Mon Jul 11, 2005 4:17 am Post subject: |
|
|
| whoo! i'll grab the latest pspsdk from svn sometime today. that pi is horrible inaccurate though :D i'll mess with the numbers later too... |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Mon Jul 11, 2005 8:17 am Post subject: |
|
|
Until the sdk is fixed for __errno just add
to your main C file.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Mon Jul 11, 2005 8:22 am Post subject: |
|
|
| It's been fixed in Subversion for quite some time. |
|
| Back to top |
|
 |
mrdelayer
Joined: 10 Jul 2005 Posts: 16
|
Posted: Mon Jul 11, 2005 10:45 am Post subject: |
|
|
blargh. grabbed it out of subversion, and now...
| Code: | Matt@steamloller /usr/local/pspdev/psp/sdk/samples/pi
$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/
pspdev/psp/sdk/lib main.o -lpspdebug -lpspdisplay -lpspge -lpspctrl -lc -lpsp
glue -lpspuser -lpspkernel -o kptest.elf
main.o: In function `find':
main.c:(.text+0x150): undefined reference to `sqrt'
main.o: In function `main':
main.c:(.text+0x2e8): undefined reference to `sqrt'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(sbrkr.o): In func
tion `_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(writer.o): In fun
ction `_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 fun
ction `_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 fun
ction `_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 fun
ction `_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 func
tion `_read_r':
../../../../../newlib/libc/reent/readr.c:58: undefined reference to `read'
collect2: ld returned 1 exit status
make: *** [kptest.elf] Error 1 |
|
|
| Back to top |
|
 |
Agoln

Joined: 08 Jun 2005 Posts: 326 Location: Fort Wayne, IN
|
Posted: Mon Jul 11, 2005 10:53 am Post subject: |
|
|
| mrdelayer wrote: | | Code: |
main.o: In function `find':
main.c:(.text+0x150): undefined reference to `sqrt'
main.o: In function `main':
main.c:(.text+0x2e8): undefined reference to `sqrt'
|
|
I'm not sure but I think you have to link the math library in to use sqrt... -lm _________________ Lego of my Ago! |
|
| Back to top |
|
 |
mrdelayer
Joined: 10 Jul 2005 Posts: 16
|
Posted: Mon Jul 11, 2005 1:35 pm Post subject: |
|
|
| that fixes that.. but not all the other stuff :| |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Mon Jul 11, 2005 4:05 pm Post subject: |
|
|
| When in doubt about undefined references, grab the latest psptoolchain from ooPo's site. We don't usually leave the tree broken for long, so chances are your SDK or tools are out of date if you get any errors. |
|
| Back to top |
|
 |
|