undefined reference to '_ctype_'
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
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
Don't use LD, if you are writing C link with gcc, if you are writing C++ link with g++.
Solves soooo many problems...
Solves soooo many problems...
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
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
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
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
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
Fixed. Grab the updated patches at http://www.oopo.net/consoledev/files/ps ... 050622.tgz.
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.