forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

undefined reference to '_ctype_'

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Paddle



Joined: 20 Jun 2005
Posts: 5

PostPosted: Wed Jun 22, 2005 8:02 am    Post subject: undefined reference to '_ctype_' Reply with quote

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
View user's profile Send private message
ReKleSS



Joined: 18 Jun 2005
Posts: 73
Location: Melbourne, Australia

PostPosted: Wed Jun 22, 2005 3:04 pm    Post subject: Reply with quote

...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
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Wed Jun 22, 2005 4:32 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Paddle



Joined: 20 Jun 2005
Posts: 5

PostPosted: Thu Jun 23, 2005 1:18 am    Post subject: Reply with quote

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
View user's profile Send private message
Paddle



Joined: 20 Jun 2005
Posts: 5

PostPosted: Thu Jun 23, 2005 1:35 am    Post subject: Reply with quote

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
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Thu Jun 23, 2005 1:36 am    Post subject: Reply with quote

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
View user's profile Send private message
Paddle



Joined: 20 Jun 2005
Posts: 5

PostPosted: Thu Jun 23, 2005 1:41 am    Post subject: Reply with quote

sweet...thanks for the response. I will also take a look there.

Cheers
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Thu Jun 23, 2005 7:08 am    Post subject: Reply with quote

Fixed. Grab the updated patches at http://www.oopo.net/consoledev/files/psptoolchain-20050622.tgz.
Back to top
View user's profile Send private message
Paddle



Joined: 20 Jun 2005
Posts: 5

PostPosted: Thu Jun 23, 2005 7:37 am    Post subject: Reply with quote

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
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Thu Jun 23, 2005 10:16 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group