undefined reference to `__ctype_b_loc'

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

Moderators: cheriff, TyRaNiD

Post Reply
hectic128
Posts: 12
Joined: Sat Nov 17, 2007 4:41 am

undefined reference to `__ctype_b_loc'

Post by hectic128 »

I'm trying to compile a program that uses an external library (agar) and am getting some strange errors that I can't figure out. They all look something like:

keymap_ascii.c:(.text+0x300): undefined reference to `__ctype_b_loc'
OR
keymap_ascii.c:(.text+0x410): undefined reference to '__ctype_toupper_loc'

Has anyone ever run across anything like this? This one has me stumped...


A few more data points:

The library and app are being built with the same version of the toolchain (and SDK libraries, etc).

As far as I know, there's nothing special about the way the library is being built (e.g. no weird compiler or linker flags).


Here's the command line when I link it, if that helps.

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -G0 -O2 -Wall -g -I.. -fno-strict-aliasing -I../.. -I/usr/local/pspdev/psp/include/agar -I/usr/local/pspdev/psp/include/SDL -I/usr/local/pspdev/psp/include -D_PSP_FW_VERSION=150 -L. -L/usr/local/pspdev/psp/sdk/lib cp.o -lag_gui -lag_core -lSDL -lpspgu -lfreetype -lpspaudio -lpsphprm -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o cp.elf

Thanks!
Hellcat
Posts: 83
Joined: Wed Jan 24, 2007 2:52 pm

Post by Hellcat »

Looks like you didn't put the agar lib into the LIBS= line in the makefile....
hectic128
Posts: 12
Joined: Sat Nov 17, 2007 4:41 am

Post by hectic128 »

Hellcat wrote:Looks like you didn't put the agar lib into the LIBS= line in the makefile....
Nope, it's there.

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -G0 -O2 -Wall -g -I.. -fno-strict-aliasing -I../.. -I/usr/local/pspdev/psp/include/agar -I/usr/local/pspdev/psp/include/SDL -I/usr/local/pspdev/psp/include -D_PSP_FW_VERSION=150 -L. -L/usr/local/pspdev/psp/sdk/lib cp.o -lag_gui -lag_core -lSDL -lpspgu -lfreetype -lpspaudio -lpsphprm -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o cp.elf

Plus, all of the other agar symbols link OK, its just these ctype ones.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Check Google.
__ctype_b_loc looks like a peculiarity of Linux libc/glibc; it's defined by the Linux Standard Base specification. PSP is not Linux and you'll have to define those symbols yourself if you want them.
hectic128
Posts: 12
Joined: Sat Nov 17, 2007 4:41 am

Post by hectic128 »

OK, I figured out the problem. When building the library, it was grabbing the ctype.h file from /usr/include rather than the PSP toolchain one...
Post Reply