| View previous topic :: View next topic |
| Author |
Message |
Paddle
Joined: 20 Jun 2005 Posts: 5
|
Posted: Wed Jun 22, 2005 8:02 am Post subject: undefined reference to '_ctype_' |
|
|
I have searched and tried many things, but still having no luck, all my code compiles, but linking, well..no. I keep getting undefined reference to '_ctype_'. All of the complaints come from standard c functions.
I'm using these flags
TOP = /usr/local/pspdev/psp/psp
LIBDIR = $(TOP)/lib
PREFIX = psp
AS = $(PREFIX)-gcc
CC = $(PREFIX)-gcc
LD = $(PREFIX)-g++
RM = /bin/rm -f
CFLAGS = $(DEFINES)
ASFLAGS = -g -c -xassembler -O
LDFLAGS = -Wl,-Ttext -Wl,8900000 -L$ (LIBDIR) -lstdc++ -lm -lc -lgcc
I have tried linking using psp-gcc. Every combination of -l(lib) I can find.
Any ideas?
Cheers |
|
| Back to top |
|
 |
ReKleSS

Joined: 18 Jun 2005 Posts: 73 Location: Melbourne, Australia
|
Posted: Wed Jun 22, 2005 3:04 pm Post subject: |
|
|
...why the heck is your linker (LD) set to g++? Try changing it to ld. I'm guessing that when you link you end up trying to link as a c++ program, when the libraries aren't working right...
-ReK |
|
| Back to top |
|
 |
Drakonite Site Admin

Joined: 17 Jan 2004 Posts: 989
|
Posted: Wed Jun 22, 2005 4:32 pm Post subject: |
|
|
Don't use LD, if you are writing C link with gcc, if you are writing C++ link with g++.
Solves soooo many problems... _________________ Shoot Pixels Not People!
Makeshift Development |
|
| Back to top |
|
 |
Paddle
Joined: 20 Jun 2005 Posts: 5
|
Posted: Thu Jun 23, 2005 1:18 am Post subject: |
|
|
As I stated in the post I have tried psp-gcc with no luck. I have found that these are the problem functions.
isalpha(c)
isupper(c)
islower(c)
isdigit(c)
isxdigit(c)
isspace(c)
ispunct(c)
isalnum(c)
isprint(c)
isgraph(c)
iscntrl(c)
They are all defined in ctype.h
I have tried to just paste the following in the hello world app, but can not get it to link. No matter what I try. The code that I'm am trying to compile only uses a couple of these and I can easily rewrite them. It just bugs me that I don't know why they aren't working. I will keep on trying to figure it out. If anyone has any ideas, please let me know.
if(isalpha(c)) pgFillvram(0);
if(isupper(c)) pgFillvram(0);
if(islower(c)) pgFillvram(0);
if(isdigit(c)) pgFillvram(0);
if(isxdigit(c)) pgFillvram(0);
if(isspace(c)) pgFillvram(0);
if(ispunct(c)) pgFillvram(0);
if(isalnum(c)) pgFillvram(0);
if(isprint(c)) pgFillvram(0);
if(isgraph(c)) pgFillvram(0);
if(iscntrl(c)) pgFillvram(0);
Cheers |
|
| Back to top |
|
 |
Paddle
Joined: 20 Jun 2005 Posts: 5
|
Posted: Thu Jun 23, 2005 1:35 am Post subject: |
|
|
Also any functions that use these won't link for me. Is this a limitation of the toolchain?
Adding this to HelloWorld
#include <stdlib.h>
char* number = "10";
char* bar;
long foo = strtol( number, &bar, 10);
if( foo == 10 ) pgFillvram(0);
gives
psp-gcc -O0 startup.o hellopsp.o kernel.o pg.o -Wl,-Ttext -Wl,8900000 -Wl,-L /
usr/local/pspdev/psp/psp/lib -lm -lc -lgcc -o out > HelloPSP.map
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(strtol.o): In
function `_strtol_r':
../../../../../newlib/libc/stdlib/strtol.c:139: undefined reference to `_ctype_'
../../../../../newlib/libc/stdlib/strtol.c:139: undefined reference to `_ctype_'
../../../../../newlib/libc/stdlib/strtol.c:186: undefined reference to `_ctype_'
../../../../../newlib/libc/stdlib/strtol.c:186: undefined reference to `_ctype_'
collect2: ld returned 1 exit status
make: *** [HelloPSP.elf] Error 1
Am I the only one getting this, has anyone else had success with these functions?
Buller...Buller...Buller...
Cheers |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Thu Jun 23, 2005 1:36 am Post subject: |
|
|
| I think it has something to do with code that was commented out in newlib (the libc that ships with psptoolchain). I'm looking into it. |
|
| Back to top |
|
 |
Paddle
Joined: 20 Jun 2005 Posts: 5
|
Posted: Thu Jun 23, 2005 1:41 am Post subject: |
|
|
sweet...thanks for the response. I will also take a look there.
Cheers |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
|
| Back to top |
|
 |
Paddle
Joined: 20 Jun 2005 Posts: 5
|
Posted: Thu Jun 23, 2005 7:37 am Post subject: |
|
|
Thank you sir!
I'm curious, was removing the patch to ctype_.c all that was needed, or is the change to the toolchain.sh also significant.
Cheers |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Thu Jun 23, 2005 10:16 am Post subject: |
|
|
| It was the addition of -DCOMPACT_CTYPE to the Allegrex-specific CFLAGS in newlib/configure.host that fixed it. GCC 4.0 seems to have a problem with aliases, so if COMPACT_CTYPE wasn't defined it would attempt to use an alias to point _ctype_ inside of another variable. Defining COMPACT_CTYPE caused _ctype_ to be created as an array instead. |
|
| Back to top |
|
 |
|